program addloop; 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:integer; begin clrscr; gotoxy (80,25); gotoxy (17,5); repeat a := 1; repeat textcolor (a); write ('-'); a := a + 1; until a = 16; num1 := num1 + 1; until num1 = 3; textcolor (green); gotoxy (33,8); write ('The Calculator'); gotoxy (33,10); textcolor(red); gotoxy (17,13); num1 := 0; repeat a := 1; repeat textcolor (a); write ('-'); a := a + 1; until a = 16; num1 := num1 + 1; until num1 = 3; 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 textcolor (green); writeln ('Welcome ',name,'. To quit the program, enter in both numbers as 0'); writeln ('Ok, ',name,', what type of math do you want to do? (type only the symbol of'); writeln ('the function you want)'); writeln; write ('+, -, *, or / ---> '); what := readkey; writeln; what := upcase(what); writeln; write ('Enter your first real number with no more than 2 decimal places. ---> '); readln (num1); writeln; write ('Now enter your second real number with a maxium of 2 decimal places. ---> '); readln (num2); while (num2 = 0) and (what = '/') do begin writeln; write ('Cant''t divide by 0, enter a different number!! ---> '); readln (num2); end; writeln; writeln; writeln; textcolor (blue); case what of '+' : answer := num1 + num2; '-' : answer := num1 - num2; '*' : answer := num1 * num2; '/' : answer := num1 / num2; end; writeln (num1:0:2,' ',what,' ',num2:0:2,' = ',answer:0:2); readln; until (num1 = 0) and (num2 = 0); end.