Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can someone help me finish my code all thats left is to display the average test score and to display the letter grade. Thanks!! ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Can someone help me finish my code all thats left is to display the average test score and to display the letter grade. Thanks!!

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

import javax.swing.JOptionPane;

/** This program demonstrates a solution to the Test Scores and Grade programming challenge. */

public class TestScoresAndGrade { public static void main(String[] args) { double test1, // Test score #1 test2, // Test score #2 test3, // Test score #3 average; // Average test score char grade; // Letter grade String input; // Input from the user

// Get three test scores from the user. input = JOptionPane.showInputDialog("Enter test score #1: "); test1 = Double.parseDouble(input); //validate test1 to make sure it is in the proper range //get input for test 2 input = JOptionPane.showInputDialog("Enter test score #2: "); test2 = Double.parseDouble(input); //validate test2 to make sure it is in the proper range //get input for test 3 input = JOptionPane.showInputDialog("Enter test score #3: "); test3 = Double.parseDouble(input); //validate test3 to make sure it is in the proper range // Calculate the average test score. average = (test1 + test2 + test3) / 3;

// Determine the letter grade. if (testScore < 60) { JOptionPane.showMessageDialog(null, "Your grade is a F."); } else if (testScore < 70) { JOptionPane.showMessageDialog(null, "Your grade is a D."); } else if (testScore < 80) { JOptionPane.showMessageDialog(null, "Your grade is a C."); } else if (testScore < 90) { JOptionPane.showMessageDialog(null, "Your grade is a B."); } else { JOptionPane.showMessageDialog(null, "Your grade is a A."); }

// Display the average test score.

// Display the letter grade. System.exit(0); } }

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

More Books

Students also viewed these Databases questions