Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program that calculates the grades for a course. Your program should prompt the user for the following information: Last Name First Name Exam

Write a program that calculates the grades for a course. Your program should prompt the user for the following information:

 Last Name First Name Exam 1 Exam 2 Exam 3 

The exams are to be weighted as follows: 25% for the first exam, 30% for the second exam, and 45% for the third exam. Based on that, a final grade is to be assigned as follows: A if the total is at least 90, B if it is at least 80, C if it is at least 70, D if it is at least 60, and F otherwise. Your program should keep repeating till user decides to quit. Display the Last Name, First Name, Final Score and Letter Grade for each student.

Data Validation: In your problem you will be doing two types of validation:

1,Input Validation: Your program must validate the user choice for repeating the program: i.e. when you give user the option to quit/add another student, validate their entry. Example:

Do you want to calculate the grades for another student [Enter y

 for Yes and n for No]: 

- if the user enters y then continue with accepting student information and calculating the grades. - if the user enters n then quit the program. - if the user enters any another value keep repeating the above prompt till user enter valid input y or n. Hint: You have seen input validation implemented in NumberGuess3.java. Think about the correct loop and valid condition for input value validation. 2,Data Type Validation: Your program must validate the console input for exam scores you will be accepting from the user. Example: Enter score for Exam 1, Exam 2 & Exam 3: User Enters: 75 80 ABC If the data type of the user entry doesnt match the data type of the variable Exam 1, Exam 2, or Exam 3, Java will throw a run time exception. Hence in our program we need to validate that the data type of the user entry matches with our program requirements (variable datatype). Hint: You have seen data type validation implemented in NumberGuess3.java. Think about the correct loop and valid condition for datatype validation. Scanner has hasNextDouble() method to check if datatype of console matched the variable datatype.

Part 1: Overall program logic (fill in the answers):

o Input: Identify the variables (along with their data types) required in the program

o Process: Formula to calculate the numerical grade for a student as well as the letter grade

o Output: Which variables need to be displayed in your output?

*Part 2: Implement in Java name the program LetterGrade.java

*Part 3: Break the program LetterGrade.java into methods

Your program must consist of at least the following methods:

calculateFinalScore(): Method that will calculate the total weighted score of Exam 1, Exam 2 and Exam 3 @param exam1, exam2, exam3 @return weighted average

calculateFinalGrade(): Method to assign a letter grade based on the final score of the student @param weightedAverage @return letter grade based on average

displayStudentGrade(): Method to display student information in the following format LastName FirstName FinalScore LetterGrade Smith Dana 92.45 A

@param lastName, firstName, finalSocre, letterGrade

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

Oracle Solaris 11.2 System Administration (oracle Press)

Authors: Harry Foxwell

1st Edition

007184421X, 9780071844215

More Books

Students also viewed these Databases questions

Question

Write the following code segment in MARIE assembly language: If x

Answered: 1 week ago

Question

If ( A^2 - A + I = 0 ), then inverse of matrix ( A ) is?

Answered: 1 week ago

Question

What is computer neworking ?

Answered: 1 week ago

Question

=+Are the contracts enforceable?

Answered: 1 week ago