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?

Reply via email to