I need to accept inputs from users (doubles). It has to output the sum and the average. If the sum is over 100 there has to be a warning message that pops up. I have to use JOptionPane Here is the code that I have thus far. It is not working at all. Please help.
package PJ2aMooreD;
import javax.swing.JOptionPane ;
public class PJ2aMooreD {
private static double Num;
public static void main (String[] args) {
double Num1 ; // Declaring user inputs
double Num2 ;
double Num3 ;
double Num4 ;
double Num5 ;
double Num6 ;
double Num7 ;
double Num8 ;
double Num9 ;
double Num10 ;
string input ;
// Prompts user to enter 10 numbers
input = JOptionPane.showInputDialog("Please enter your first number ") ;
Num1 = double.parseDouble(input) ;
input = JOptionPane.showInputDialog("Please enter your second number ") ;
Num2 = double.parseDouble(input) ;
input = JOptionPane.showInputDialog("Please enter your third number ") ;
Num3 = double.parseDouble(input) ;
input = JOptionPane.showInputDialog("Please enter your fourth number ") ;
Num4 = double.parseDouble(input) ;
input = JOptionPane.showInputDialog("Please enter your fifth number ") ;
Num5 = double.parseDouble(input) ;
input = JOptionPane.showInputDialog("Please enter your sixth number ") ;
Num6 = double.parseDouble(input) ;
input = JOptionPane.showInputDialog("Please enter your seventh number ") ;
Num7 = double.parseDoublee(input) ;
input = JOptionPane.showInputDialog("Please enter your eighth number ") ;
Num8 = double.parseDouble(input) ;
input = JOptionPane.showInputDialog("Please enter your ninth number ") ;
Num9 = double.parseDouble(input) ;
input = JOptionPane.showInputDialog("Please enter your tenth number ") ;
Num10 = double.parseDouble(input) ;
// Calculates the sum and the average from the user’s input
double sum = (Num1 + Num2 + Num3 + Num4 + Num5 + Num6 + Num 7 + Num8 + Num9 + Num10) ;
double average = (sum / 3.0) ;
// Shows the message indicating the user’s average and sum
String avg = String.format("%.2f",average) ;
JOptionPane.showMessageDialog(null, "sum = " + sum + "\naverage = " + avg ) ;
// Returns a Warning Message based on the results from the user’s input
if(sum > 100) ;
JOptionPane.showMessageDialog(null, “Values have exceeded a sum of 100 ") ;"
if else ;
private static double stringparseDouble(string input) {
throw new UnsupportedOperationException("Not yet implemented");
}
private static double dstringparseDouble(string input) {
throw new UnsupportedOperationException("Not yet implemented");
}
private static class string {
public string() {
}
}
private static class sum {
public sum() {
}
}
JOptionPane.showMessageDialog(null, “No warning needed “) ;
}