Here is the code:
import java.io.IOException;
import java.math.*;
import javax.swing.JOptionPane;
public class Student
{
public static void main(String[] args)
{
//double(quiz1, quiz2, quiz3, quiz4, average, TotalScore);
String name = JOptionPane.showInputDialog(null, "What is your name?");
JOptionPane.showMessageDialog(null, "Hello, " + name + ".");
String quiz1 = JOptionPane.showInputDialog(null, "Enter Quiz 1 score");
JOptionPane.showMessageDialog(null,name + ", your Quiz 1 score is " + quiz1 + " points.");
String quiz2 = JOptionPane.showInputDialog(null, "Enter Quiz 2 score");
JOptionPane.showMessageDialog(null,name + ", your Quiz 2 score is " + quiz2 + " points.");
String quiz3 = JOptionPane.showInputDialog(null, "Enter Quiz 3 score");
JOptionPane.showMessageDialog(null,name + ", your Quiz 3 score is " + quiz3 + " points.");
String quiz4 = JOptionPane.showInputDialog(null, "Enter Quiz 4 score");
JOptionPane.showMessageDialog(null,name + ", your Quiz 4 score is " + quiz4 + " points.");
String TotalScore = quiz1 + quiz2 + quiz3 + quiz4;
JOptionPane.showMessageDialog(null, name + ", your totalscore is " + TotalScore);
String average = quiz1 + quiz2 + quiz3 + quiz4 / 4;
JOptionPane.showMessageDialog(null, name + ", your current Average is: " + average + "%");
}
}
and the output:
run:
Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - bad operand types for binary operator '/'
first type: java.lang.String
second type: int
at Student.main(Student.java:28)
Java Result: 1
BUILD SUCCESSFUL (total time: 14 seconds)
made using Netbeans.

New Topic/Question
Reply




MultiQuote







|