Question: Write a program using the structured programming approach that determines a student's grade. It reads three test scores (between 0 and 100) and calculates the
Write a program using the structured programming approach that determines a student's grade. It reads three test scores (between 0 and 100) and calculates the average score and converts it to a letter grade. Average Score Calculation: Average Score = (Test Score 1 + Test Score 2 + Test Scores 3) /3 Grade Conversion Rules:
rule a. If the average score is 90 or more the grade is 'A'.
rule b. If the average score is 70 or more and less than 90 then check the third test score. If the third score is 90 or more the grade is 'A' otherwise the grade is 'B'.
rule c. If the average score is 50 or more and less than 70 then check the average of the second and third scores. If the average of the last two is 70 or more, the grade is 'C' otherwise it is a 'D'
rule d. If the average score is less than 50 then the grade is 'F'.
Rounding Rule: Midpoint Rounding Calculate the grade average as a double. Round up to the next int if the fractional part is .5 or greater, otherwise truncate the fraction by casting to an int. The algorithm is: Add .5 to the average and cast the result to an int. Example: average = (int)(average+0.5);
Create a new project in Visual Studio or other IDE, name it FirstName_LastName_A3 where FirstName is your first name and LastName is your last name. Submit your zipped project folder in Eagle online.
To solve this problem, we can identify IPO and develop the Pseudocode.
1. Input: three test scores
2. Processing: Calculate the average and convert it to letter grade according to the conversion rules.
3. Output: Display the letter grade
4. Variables: int test1, test2, test2 double average, average2 char letterGrade
5. Constants: none
Detailed Pseudocode: 1. Prompt user to enter first test score
2. Read user input and store value into variable test1
3. Prompt user to enter second test score
4. Read user input and store value into the variable test2
5. Prompt user to enter third test score
6. Read user input and store value into the variable test3
7. average = (test1 + test2 + test3) / 3.0 //use 3.0 to avoid integer division average = (int) (average +0.5) //apply rounding rule
8. average2 = (test2+test3) / 2.0 //use 2.0 to avoid integer division 1/16/2017 COSC 1436 Programming Fundamentals I C# average2 = (int) (average2+0.5) //apply rounding rule
9. if (average >=90) letterGrade=A else if (average >=70) if (test3 >= 90) letterGrade=A else letterGrade=B else if (average >=50) if (average2>=70) letterGrade=C else letterGrade=D else letterGrade=F
10. Display letterGrade Once the above detailed pseudocode is developed, you can map it line by line into C# code.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
