Results 1 to 4 of 4
  1. #1
    januaryako is offline Member
    Join Date
    Feb 2012
    Posts
    3
    Rep Power
    0

    Default 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:

    Java 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);
    }
    }
    Last edited by januaryako; 02-19-2012 at 01:40 AM. Reason: code tags added

  2. #2
    fatabass is offline Senior Member
    Join Date
    Nov 2011
    Location
    Turkey
    Posts
    380
    Blog Entries
    24
    Rep Power
    3

    Default Re: How to display a grid using dialog box?

    I think you should remove the + after null, and what is ave ?

  3. #3
    januaryako is offline Member
    Join Date
    Feb 2012
    Posts
    3
    Rep Power
    0

    Default 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

  4. #4
    januaryako is offline Member
    Join Date
    Feb 2012
    Posts
    3
    Rep Power
    0

    Default 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

Similar Threads

  1. Struts: How to display a grid in Struts??
    By fabbero in forum New To Java
    Replies: 1
    Last Post: 07-13-2011, 05:18 PM
  2. Replies: 4
    Last Post: 05-15-2011, 04:47 AM
  3. Replies: 13
    Last Post: 03-20-2010, 01:03 AM
  4. Replies: 8
    Last Post: 12-29-2008, 07:12 AM
  5. Replies: 0
    Last Post: 04-04-2008, 12:15 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •