// Dick cs201/lab/05 Illogical.cc // Date: Mon May 1 06:28:10 PDT 1995 // WARNING: This has bugs... find them // also I don't use this in my grading ... /* -------------Problem------------ To convert letter grades into per centage scores according to rules in the syllabus... using middle of ranges. -------------Analysis----------- DATA REQUIREMENTS Constants a,b,c,d,f (int) values of grades 'a', 'b', ... Inputs grade (char) Outputs percent (int) FORMULAE see cs201/syllabus a=100%, b=85%, c=75%, d=65%, f=30% --------------Design------------- INITIAL ALGORITHM 1, read the grade 2. convert to percent 3. display percent REFINEMENTS 2. To convert to percent 2.1 if grade is 'A' then percent is a 2.2 if grade is 'B' then percent is b 2.3 if grade is 'C' then percent is c 2.4 if grade is 'D' then percent is d 2.5 else percent is e. ------------Implementation--------- */ #include int main( ) { const int a =100; const int b = 85; const int c = 75; const int d = 65; const int f = 30; char grade; int percent; cout << "Input the grade> "; cin >> grade; if(grade = 'A') percent = a; else if(grade == 'B') percent = b; else if(grade == 'C') percent = c; else if(grade == 'D') percent = d; else percent = f; cout << percent <<"%"; return 0; // terminate program with an "all ok" result returned to UNIX }