****************************************************************** ***************** Assignment #2 for CS341 ********************* ***** Due Monday 02/15/99 ***** ****************************************************************** Reading Assignment: Chapters 3-7 of the lab manual. ------------------ The goal of the programming assignment is to learn the use of the following: (i) Branch instructions (ii) Multiply and Divide instructions (iii) Screen/keyboard I/O Programming Assignment ---------------------- Translate the following into SPARC assembly language and make sure it runs satisfactorily. # include main() { int nc, i; int ctemp; char gtemp; int ctot=0; int cum =0; cout << "\n Enter # of courses: "; cin >> nc; for (i=0; i< nc; i++) { cout << "\n Enter # of credit hours: "; cin >> ctemp; cout << "\n Enter Grade (one of A, B, C or D): "; cin >> gtemp; ctot += ctemp; switch (gtemp) { case 'A': cum += 4*ctemp; break; case 'B': cum += 3*ctemp; break; case 'C': cum += 2*ctemp; break; case 'D': cum += 1*ctemp; break; default: cout <<"\n Error, quitting\n"; break; } } cout << "\n Total # of credit hours = " << ctot; cout << "\n GPA = " << (float)cum/(float)ctot ; cout << "\n \n " ; } Note: Compute GPA to only two decimal places. ----