D Program code on CLS

Vincent spawn_rock2000 at yahoo.com
Wed Nov 13 20:59:08 PST 2013


import std.stdio,std.cstream;

void main(string[] args)
{
	while (true)
	{
		writeln ("Calculator Menu");
		writeln();
		writeln();
		writeln (" 1 - Add");
		writeln (" 2 - Subtract");
		writeln (" 3 - Multiply");
		writeln (" 4 - Divide");
		writeln (" 5 - EXIT");
		writeln();
		write ("Selected Number: ");
						
		int operation;
		readf (" %s", &operation);
		
		if ((operation < 1) || (operation > 5))
		{
			writeln ("Invalid Operation");
			readln();
			readln();
			continue;
		}
		if (operation == 5)
		{
			writeln ("Goodbye!!!");
			readln();
			readln();
			break;
		}
		
		int first;
		int second;
				
		write ("First Number:    ");
		readf (" %s", &first);
		
		write ("Second Number:   ");
		readf (" %s", &second);
		
		int result;
		
		if (operation == 1)
		{
			result = first + second;
		}
		else if (operation == 2)
		{
			result = first - second;
		}
		else if (operation == 3)
		{
			result = first * second;
		}
		else if (operation == 4)
		{
			result = first / second;
		}
			else
		{
			writeln ("There is an error!");
			writeln ("This condition should never occurred.");
			break;
		}
		writeln ("Result     : ", result);
		readln();
		din.getc();
	}
}

--------------------------
This is the code. where or what code will I use for clear the 
screen?


More information about the Digitalmars-d-learn mailing list