Question
This assignment is based on Assignment 3 and rewrite it using multiple methods to calculate the student average and letter grade. The followings are the
This assignment is based on Assignment 3 and rewrite it using multiple methods to calculate the student average and letter grade. The followings are the rules of calculating the average and 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.
Methods required in the project:
GradesInput() Get 3 test scores from the user and pass back 3 test scores to the calling method
Average3Scores() Average three test scores and apply the rounding rule and return the average.
AverageLast2Scores() Average last 2 test scores and apply the rounding rule and return the average.
ToLetterGrade() Convert average grade to letter grade according the grade conversion rules and return the letter grade.
DisplayGrade() Display both average grade and letter grade, and do not return anything. Create a new project in Visual Studio.
Program Design This assignment is using method to reorganize your code. You can take assignment 3 that you have completed as the base code and add the methods below and call all the methods inside of your main() method. Each of the method will replace the code in your main() method that you wrote in assignment 3. After all the methods have been called, your main() will be very short and organized.
Here are the layout for each method
static void GradesInput(out int s1, out int s2, out int s3)
{
//Prompt user to enter the first test score //Read the test score and store it into s1 //Validate the test input to make sure it is between 0 and 100 //Prompt user to enter the second test score //Read the test score and store it into s2 //Validate the test input to make sure it is between 0 and 100 //Prompt user to enter the third test score //Read the test score and store it into s3 //Validate the test input to make sure it is between 0 and 100 } static double average3Scores(int s1, int s2, int s3) { //Declare a double variable to hold average //Calculate average by adding three scores (s1, s2, and s3) and divided it by 3.0 //Apply rounding rule //return average } static double average2Scores(int s2, int s3) { //Declare a double variable to hold average of 2 test scores //Calculate average by adding two test scores (s2 and s3) and divided it by 2.0 //Apply rounding rule //return average } static char toLetterGrade(double avg, double avg2 ,int s3) { //Declare a letter grade variable //Apply grade conversion rule using if.. else if statement //return letter grade } static void displayGrade(double avg, char lGrade) { //Display average of 3 test scores (avg) //Display letter grade (lGrade) }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started