Question
The java code below is building successfully but when I run it its coming up with an error message and there is no dialog box.
The java code below is building successfully but when I run it its coming up with an error message and there is no dialog box. Can I get some help and pointers where I am going wrong?
import javax.swing.JOptionPane;
/** This program demonstrates using dialogs with JOptionPane. */
public class ScoreDialog1 { public static void main(String[] args) { String inputString; // For reading input int Score1; // first score int Score2; // second scpre int Score3; // third score double Average; // The average
// Get the user's scores. inputString = JOptionPane.showInputDialog("Score1 ");
// Convert the input to an int. Score1 = Integer.parseInt(inputString); inputString = JOptionPane.showInputDialog("Score2 ");
// Convert the input to an int. Score2 = Integer.parseInt(inputString); inputString = JOptionPane.showInputDialog("Score3 ");
// Convert the input to an int. Score3 = Integer.parseInt(inputString); // Get the hourly pay rate. inputString = JOptionPane.showInputDialog("What is the average? ");
// Convert the input to a double. Average = Double.parseDouble(inputString); // Calculate the gross pay. Average = (Score1 + Score2 + Score3) /3.0; // Display the results. JOptionPane.showMessageDialog(null, "Score1 = " + Score1 + " ");
JOptionPane.showMessageDialog(null, "Score2 = " + Score2 + " ");
JOptionPane.showMessageDialog(null, "Score3 = " + Score3 + " ");
JOptionPane.showMessageDialog(null, "Average = " + Average +" ");
// End the program. System.exit(0); } }
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