For this Lab, you will have to write a java program that asks the user to enter grades for homework, midterm exam, and final exam. The program will calculate the final grade of the student and its corresponding letter grade.

Formula to calculate final grade:

Final Grade= (Final_Exam*50%)+(Midterm_Exam*25%)+(Homework*25%)

Please follow these guidelines and ask your TA for help if needed. You may also collaborate with your classmates if needed.

Assignments Documentation:

At the beginning of each programming assignment you must have a comment block with the following information:

/*-------------------------------------------------------------------------
// AUTHOR: your name
// FILENAME: title of the source file
// SPECIFICATION: description of the program
// FOR: CSE 110- Lab #3
// TIME SPENT: how long it took you to complete the assignment
//----------------------------------------------------------*/

Getting started:

Step1: Create a class called Lab3. Use the same setup for setting up your class and main method as you did in previous assignments. Be sure to name your file Lab3.java.

Part1: Declaring variables

When we examine this programming task, we see that we will need three inputs from the user: Midterm Grade, Final Grade, and Homework Grade. All of them can be declared as double type. In order to calculate the final grade, we will need to declare a variable that will hold the final grade value. We also need to declare a String data type variable that will hold the Letter Grade.

Note: //--> Indicates a place where you should add code.

// class name should match the file name

public class Lab3
{
// we must have a main method to run the program
public static void main(String[] args)
{
// declare variables of different types:
// a double called finalexamGrade
//-->
// a double called homeworkGrade
//-->
// a double called midtermGrade
//-->
// a double called finalGrade
//-->
// a String called letterGrade
//-->
// a variable scan of type Scanner
//-->

Part 2:

Write a segment of code where you will ask the user to provide values to the variables you just declared (finalexamGrade, homeworkGrade, midtermGrade)

// Use the Scanner class to ask the user
//for their final exam grade and store the
// input in the ‘finalexamGrade variable.
//-->
// Use the Scanner class to ask the user for
// their homework grade and store the
// input in the ‘homeworkGrade variable.
//-->
// Use the Scanner class to ask the user for
//their midterm grade and store the
// input in the ‘midtermGrade variable
//-->

Part 3:

Now that we have the final exam grade, homework grade, and midterm grade we can calculate the final grade using the following formula:

finalGrade= (finalexamGrade *50%)+(midtermExam*25%)+(homeworkGrde*25%)
//write the formula to calculate the final grade
//and store the result in the “finalGrade” variable
//-->

Part 4:

Now that we have the final grade, we can calculate its corresponding letter grade. Use the if else if finalGrade= (finalexamGrade *50%)+(midtermExam*25%)+(homeworkGrde*25%) else statement to do so.

If “finalGrade” between 90 and 100, letterGrade is “A”.
If “finalGrade” between 80 and 90, letterGrade is “B”.
If “finalGrade” between 70 and 80, letterGrade is “C”.
If “finalGrade” between 60 and 70, letterGrade is “D”.
If “finalGrade” less than 60, letterGrade is “F”.

Part 5:

Use a switch statement to write a segment of code that uses the students Letter Grade as an input argument and display the output of your program. You should print the final grade, the letter grade, and the comment to the grades provided by the user as follows: (Perfect Score) for letter grade A, B (Good Score), C (Average), D (Below Average) and F (Not Passing).

switch (letterGrade)
{
//include all cases
//here is an example when letterGrade is equals to “A”
Case “A”:
System.out.println ("The final grade for this student is < finalGrade >”);
System.out.println ("The letter Grade is < letterGrade >");
System.out.println ("Feedback from the professor: Perfect Score");
//print a feedback for each letter grade.
//-->
//-->
//-->
//-->

Sample Output

Below is an example of what your output should roughly look like when this lab is completed.

Sample Run 1:
Enter final exam grade: 75
Enter midterm grade: 90
Enter homework grade: 95
The final grade of this student is 83.65
The letter grade is “B”
Feedback from the professor: Good Score

Sample Run 2:
Enter final exam grade: 90
Enter midterm grade: 90
Enter homework grade: 95
The final grade of this student is 91.25
The letter grade is “A”
Feedback from the professor: Perfect Score
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.