program asmd; uses crt; {-------------------------------------------------------------------------- program description This program asks you what type of math you want to do, then asks for 2 numbers. Depending on what you answered to the first question, the program will either add, subtract, multiply, or divide the numbers and then print the output on the screen. You will then be asked if you want to do more math. If you do, the program will restart. --------------------------------------------------------------------------} VAR num1, num2, answer:real ; what, again:char ; name:string ; a,b: integer; {-------------------------------------------------------------} begin clrscr; gotoxy (80,25); gotoxy (17,5); for b := 1 to 3 do for a := 1 to 15 do begin textcolor (a); write ('-'); end; textcolor (green); gotoxy (33,8); write ('The Calculator'); gotoxy (33,10); textcolor(red); writeln ('By'); gotoxy (17,13); for b := 1 to 3 do for a := 1 to 15 do begin textcolor (a); write ('-'); end; gotoxy (50,20); textcolor(blue); writeln ('Press any key to Continue'); readkey; clrscr; textcolor (6); write ('What''s your name? ---> '); readln (name); writeln; writeln; repeat if again = 'y' then clrscr; textcolor (green); writeln ('Ok, ',name,', what type of math do you want to do? (type only the function''s first'); writeln ('letter)'); writeln; write ('Multipy, Divide, Add, Subtract ---> '); what := readkey; writeln; what := upcase(what); writeln; write ('Enter your first real number with no more than 2 decimal places. ---> '); readln (num1); writeln; repeat write ('Now enter your second real number with a maxium of 2 decimal places. ---> '); readln (num2); until (what <> 'D') or (num2 <> 0); writeln; writeln; writeln; textcolor (blue); case what of 'A' : answer := num1 + num2; 'S' : answer := num1 - num2; 'M' : answer := num1 * num2; 'D' : answer := num1 / num2; end; case what of 'A' : what := '+'; 'S' : what := '-'; 'M' : what := '*'; 'D' : what := '/'; end; writeln (num1:0:2,' ',what,' ',num2:0:2,' = ',answer:0:2); textcolor (green); writeln; writeln; writeln; writeln ('Hey ',name,', do you want to do some more math?'); write ('Type "y" for yes or "n" for no. ---> '); again := readkey; again := upcase(again); until again = 'N'; end.