Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In JAVA PLEASE 5.19 Programming Lab 2: Grade Calculator With Methods This lab will be available until February 6th, 11:59 PM EST Instructor note: This

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

In JAVA PLEASE

5.19 Programming Lab 2: Grade Calculator With Methods This lab will be available until February 6th, 11:59 PM EST Instructor note: This Lab will be more challenging than Programming Lab 1. We need to start learning how to write "one large program" using all of the topics we have learned. This includes variables, Decisions, Loops, and Methods. Please read the instructions carefully. You may prefer to download the template, complete in an IDE, and copy and paste your solution. You will be required to put in proper Java commenting (10 pts), so please include. I will manually review your code and can deduct up to 10 pts. for comments or not following the program specifications. In this Programming Lab, we are going to learn how to use Methods to make our code more effective and handle "separation of concerns". Think of methods like functions - each method handles one specific problem or task, but is able to be called/reused as many times as needed. The purpose of this program is to prompt the student to input their grades for each category, find the student's grade average for each category, and use these averages to calculate the user's final grade average and letter grade. This is similar to Programming Lab 1, but with methods and loops. We will break our code down into several methods that each have one specific purpose. One to handle the homework grades, one to handle the test grades, one to handle the midterm grade, one to handle the final exam grade, and one to find the letter grade associated with the given numerical grade. Step 1: - A Scanner object in and constants have been declared for you in the main method inside the template code. Please leave these in. - We will return to the main method after writing all our methods. (This is common practice - write methods and then call them). Step 2: - Write a method getHomeworkAverage(Scanner in) that takes the Scanner object as a parameter and returns the homework average as type double. The method header and commenting has been written for you. - Inside this method, use a print statement to prompt the user for the number of grades to be entered for homework. - Write a method getHomeworkAverage(Scanner in) that takes the Scanner object as a parameter and returns the homework average as type double. The method header and commenting has been written for you. - Inside this method, use a print statement to prompt the user for the number of grades to be entered for homework. - Declare a count variable as integer and store the input. - Declare a sum variable and initialize to 0. - Use a for loop that counts from 0 up to count. - Inside the for loop, use a print statement to prompt the user for the individual grades. - Read in the input and add it to the sum. - Outside of the for loop, create a variable homeworkAverage and store the calculated average in the variable (averages are total sum / count). - return the homework average from the method. Example of getHomeworkAverage method executing: How many homework grades to be entered?: 4 Grade 1: 78.6 Grade 2: 89 Grade 3:76.4 Grade 4: 91 Step 3: - Write a method getTestaverage(*parameter here*) that returns a double. Follow the same instructions in Step 2 to read in a user's test grades and calculate the average. Remember to return the test average and comment your method above the method with @ tags, as needed. Example of getTestAverage method executing: How many tests grades to be entered?: 2 Grade 1: 78.9 Grade 2: 88 Step 4: - Write a method getMidtermExamGrade(*parameter here*) that returns a type double. - Inside this method, prompt the user to enter their midterm exam grade (no for loop needed as only one score can be entered) and store the input. - return the midterm exam grade. - Write a method getMidtermExamGrade(*parameter here*) that returns a type double. - Inside this method, prompt the user to enter their midterm exam grade (no for loop needed as only one score can be entered) and store the input. - return the midterm exam grade. Example of getMidtermExamGrade method executing: Please enter your midterm exam grade: 82.3 Step 5: - Write a method getFinalExamGrade(*parameter here*) that returns a type double. - Inside this method, prompt the user to enter their final exam grade (no for loop needed as only one score can be entered) and store the input. - return the final exam grade. Example of getFinalExamGrade method executing: Please enter your final exam grade: 90.1 Step 6: - Write a method getLetterGrade(*parameter here*) that takes a numerical finalGrade as a parameter and returns a String. - Inside this method, the String variable letterGrade has been declared for you. - Use an if/else if/else statement to check if the finalGrade is an A, B, C, D, or F. We will use a 10-point scale where >= 90 is an A,>=80 is a B, etc. - Inside each if/else statement, assign a String "Course grade: X ", where X is the letter grade. - return the letter grade. - **NOTE: Please make sure you are not *printing the String in this method. We will print it in the main method. Example of getLetterGrade method executing: Step 7: - Return back to the main method. - Call the 4 methods for homework, tests, midterm, and final, passing the Scanner object as a parameter to each. Make sure to store the return values in appropriate variables. Step 7: - Return back to the main method. - Call the 4 methods for homework, tests, midterm, and final, passing the Scanner object as a parameter to each. Make sure to store the return values in appropriate variables. - Calculate the final numerical grade average using the variables and the constants that were declared above (grade average is the sum of all of the averages * CONSTANT) - Use a printf statement to output the final grade average to 2 decimal places. - Call the getLetterGrade method, passing the final grade average as a parameter. - Use a println statement to output the letter grade. Entire run of program in an IDE (this is formatted): How many homework grades to be entered?: 4 Grade 1: 78.6 Grade 2: 89 Grade 3:76.4 Grade 4: 91 How many tests grades to be entered?: 2 Grade 1: 78.9 Grade 2: 88 Please enter your midterm exam grade: 82.3 Please enter your final exam grade: 90.1 Your final grade is: 85.16 Course grade: B Remember to comment your code per the "Java Coding RULES" doc in iCollege (10 pts). NOTE: The output in zyLabs will not show the formatting in the testing output. It will appear as one long run-on sentence. Therefore, I recommend downloading the given template, writing the program in your IDE, and then copy and paste back over. How many homework grades to be entered?: Grade 1: Grade 2: Grade 3: Grade 4: How many tests grades to be entered?: Grade 1: Grade 2: Please enter your midterm exam grade: Please enter your final exam grade: Your final grade is: 85.16 Course grade: B The input in zyLabs is of the form: 478.68976.491 where 4 is the number of grades being entered and the other 4 values are the grades. 435776.2817900.q32qy7 \begin{tabular}{l|l} LAB & 5.19.1: Programming Lab 2: Grade Calculator With Methods \\ ACTIVITY & 5.1. \end{tabular} Downloadable files GradeCalculatorWithMethods.ja GradeCalculatorWithMethods.java Load default template... public static void main(String[] args) \{ //Initialize a Scanner object Scanner in = new Scanner(System.in); //Constants represent weight of categories final double HOMEWORK =.20; final double TESTS =0.20; final double MIDTERM =0.30; final double FINAL_EXAM =0.30; //Call the homework, test, midterm, and final exam methods and store return value GradeCalculatorWithMethods.java

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Database Factory Active Database For Enterprise Computing

Authors: Schur, Stephen

1st Edition

0471558443, 9780471558446

More Books

Students also viewed these Databases questions