http://www.math.ucla.edu/~dinov/10a.3.01s/ |

- (
**HW_5_1.cpp/exe**) In this exercise we have to design a program that calculates our**final grades**in PIC10A, in the Spring 2001, UCLA PIC. You need to write a program that reads from an ASCII file, in that order, the scores for 7 Homeworks (HW's), a Midterm and a Final exam. The lowest HW grade is dropped and the remaining 6 grades are averaged to obtain the average HW score, this counts with weight 30% to the final grade. Midterm counts as 30% also, and the Final exam is worth 40% of the final grade. You need to read in all these scores (integers), calculate the number representation of your final grade (e.g., 79/100) according to the above distribution and report the mean and the standard deviation of the sequence of all 9 scores (HW's and exam grades). Suggest a letter grade based on the obtained numeric grade (100-90, A; 80-89, B; 70-79, C; 60-69, D; below 60, F). You can report all results as integers, however, all calculations should be carried out using double arithmetic. There is only one specific design requirement you need to follow. Define a**HomeworkScores**structure, containing all HW scores, and a**Grades**structure containing a variable of type**HomeworkScores**and two other variables for the Midterm and the Final Exam scores. You need to instantiate all variables to the values read from**myGradesPIC10A.dat**file and access them using the*structure member access*protocol we discussed in class. [Note: the**mean/standard deviation**are defined by: SD{x_{1},x_{2}, ..., x_{n}} = sqrt( (1/(n-1)) * ( (x_{1}-m)^{2}+ (x_{2}-m)^{2 }+ ... +(x_{n}-m)^{2}) ),**mean m=(1/n)(x**and_{1}+ x_{2}+ ...+ x_{n})**sqrt**is the square-root function.]

**Sample Run:**Suppose one student's record is as follows:*80, 70, 90, 100, 70, 80, 60, 70, 80*, and these are stored in a file**myGradesPIC10A.dat**

%> Enter the name of the file containing your 7 HW and 2 Exam grades:

%> myGradesPIC10A.dat

%> HW:**7**, was your lowest grade homework and it is dropped

%> Your final numeric grade (based on the 30%+30%+40% distribution) is: 78

%> Most likely you will get a**C**in PIC 10A in the Spring 2001

%> Your overall grade mean (using all 9 scores) is: 78

%> with approx. std error (standard deviation) of: 11

%> Good work. Bye!

- (
**HW_5_2.cpp/exe**) Write a program that reads a line from the standard input and swaps all lower-case characters to upper-case, and all upper-case letters to lower-case.

**Sample Run:**

%> This program inverts the letter-case. Please enter a line of text that needs to be inverted:

%> This Is a tesT linE 123.

%> Inverted text looks like: tHIS iS A TESt LINe 123.

%> Would you like to invert another line (y/n)?

%> y

%> This Is aNoThEr tesT linE.

%> Inverted text looks like: tHIS iS AnOtHeR TESt LINe.

%> Would you like to invert another line (y/n)?

%> n

%> Goodbye!