How to display a grid using dialog box?
Hi could somebody please help me. I am currently making a program that will get the average of the 3 scores of each of the 2 subjects.(math and english). I'm done making the program but the thing that I can't seem to make is how to display it inside a grid using a dialog box. I tried using special alt keys to manually make it but it didn't work. Here's my code:
Code:
import javax.swing.*;
public class average
{
public static void main(String[]args)
{
int eng1,eng2,eng3,math1,math2,math3;
double ave1,ave2;
String S1;
S1 = JOptionPane.showInputDialog("Enter 1st Quiz Grade in English: ");
eng1 = Integer.parseInt(S1);
S1 = JOptionPane.showInputDialog("Enter 2st Quiz Grade in English: ");
eng2 = Integer.parseInt(S1);
S1 = JOptionPane.showInputDialog("Enter 3st Quiz Grade in English: ");
eng3 = Integer.parseInt(S1);
S1 = JOptionPane.showInputDialog("Enter 3st Quiz Grade in English: ");
math1 = Integer.parseInt(S1);
S1 = JOptionPane.showInputDialog("Enter 3st Quiz Grade in English: ");
math2= Integer.parseInt(S1);
S1 = JOptionPane.showInputDialog("Enter 3st Quiz Grade in English: ");
math3 = Integer.parseInt(S1);
ave1=(math1+math2+math3)/3;
ave2=(eng1+eng2+eng3)/3;
JOptionPane.showMessageDialog(null,
"\nSubject 1 2 3"
+"\nEnglish " +" "+eng1+" " +eng2+" "+eng3
+"\nMathematics " +" "+math1+ " " +math2+ " " +math3
+"\n Math Gen Ave"+ave1
+"\n English Gen Ave"+ave2,"Report", JOptionPane.INFORMATION_MESSAGE);
}
}
Re: How to display a grid using dialog box?
I think you should remove the + after null, and what is ave ?
Re: How to display a grid using dialog box?
ohh sorry forgot to remvoe the + after the null, wait let me fix it. the ave should be only one for each subject hehe
Re: How to display a grid using dialog box?
done fixing the bugs. Can somebody teach me how to display it output inside a grid in a dialog box? Thank you