program testavg; uses crt; {-------------------------------------------------------------------------- This program will find the total grade for a group of 3 weighted tests. --------------------------------------------------------------------------} VAR a,x,r,b,c,t:real; g:integer; j:char; begin repeat clrscr; textcolor(green); write ('What is the grade for the first test? ---> '); readln (x); write ('and the weight, as a decimal? ---> '); readln (r); t := r; a := x * r; writeln; write ('second? ---> '); readln (x); write ('and the weight, as a decimal? ---> '); readln (r); t := t + r; b := x * r; writeln; write ('third? ---> '); readln (x); write ('and the weight, as a decimal? ---> '); readln (r); t := t + r; c := x * r; writeln; writeln; writeln; if t <> 1 then begin textcolor (red + blink); writeln ('WARNING:YOUR WEIGHTS DO NOT ADD UP TO 100%'); writeln ('Did you mess up, and want to start over? '); j := readkey; writeln; writeln; textcolor(green); end else j := 'n'; until j = 'n'; writeln ('The weighted score for the first test is ',a:0:1); writeln ('The weighted score for the second test is ',b:0:1); writeln ('The weighted score for the third test is ',c:0:1); writeln; a := a + b + c ; writeln ('The overall weighted grade is ',a:0:1); a := a * 10; g := round(a); case g of 1000 : writeln ('You''ve got an A+!') ; 925..1000 : writeln ('You''ve got an A!') ; 900..925 : writeln ('You''ve got an A-!') ; 875..900 : writeln ('You''ve got a B+') ; 825..875 : writeln ('You''ve got a B') ; 800..825 : writeln ('You''ve got a B-') ; 775..800 : writeln ('You''ve got a C+') ; 725..775 : writeln ('You''ve got a C') ; 700..725 : writeln ('You''ve got a C-') ; 675..700 : writeln ('You''ve got a D+') ; 625..675 : writeln ('You''ve got a D') ; 600..700 : writeln ('You''ve got a D-') ; 0..600 : writeln ('You''ve got a F') ; else writeln ('You messed up... you''re grade is either above 100 or below 0'); end; if a >= 60 then writeln ('You''ve got a passing grade!') else writeln ('Better improve your grade... you''re not passing'); readln; end.