Results 1 to 4 of 4
  1. #1
    511prs is offline Member
    Join Date
    Aug 2012
    Posts
    6
    Rep Power
    0

    Exclamation Help with my code!

    Hi! I'm writing a very simple program that tells you about your grades, it ask you for 3 different grades but when it ask you is in 3 different windows I would like to know how to put the three input dialogs in just one window, let me show you

    import javax.swing.JOptionPane;

    public class MoyenneNotes
    {

    /**
    * @param args
    */
    public static void main(String[] args)
    {
    //Déclarations
    float note1, note2, note3;
    float moyenne;

    //THIS IS WHAT I WANT TO PUT IN JUST ONE WINDOW
    note1 = Float.parseFloat((JOptionPane.showInputDialog(null , "Entrez la première note:")));
    note2 = Float.parseFloat((JOptionPane.showInputDialog(null , "Entrez la deuxième note:")));
    note3 = Float.parseFloat((JOptionPane.showInputDialog(null , "Entrez la troisieme note:")));
    if (note3 <= 0) {
    note3 = Float.parseFloat((JOptionPane.showInputDialog(null , "Entrez la troisieme note!")));
    }

    //Calculs
    moyenne = (float) (note1 + note2 + note3)/3;
    JOptionPane.showMessageDialog(null, "La moyenne est: " + moyenne);
    if (moyenne < 60) {
    moyenne = Float((JOptionPane.showConfirmDialog(null, "Vous allez echouer votre saision, Desole")));
    } else {
    moyenne = Float((JOptionPane.showConfirmDialog(null, "Felicitation! Vous Allez reussir votre saision")));

    }
    I really appreciate your help

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,883
    Rep Power
    25

    Default Re: Help with my code!

    A problem would be that the JOptionPane class's method only returns a single value.

    Another more complicated way to display a dialog and get multiple responses would be with a custom dialog that has input fields the user can fill in and buttons the user can push when done filling in the fields. The fields shown in the dialog would be available to the caller to get their contents using some get method.

    See the tutorial: http://docs.oracle.com/javase/tutori...ts/dialog.html
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    511prs is offline Member
    Join Date
    Aug 2012
    Posts
    6
    Rep Power
    0

    Default Re: Help with my code!

    hey thank you very much! it really help me! I appreciate your help

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,458
    Rep Power
    20

    Default Re: Help with my code!

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Replies: 16
    Last Post: 01-31-2012, 09:36 PM
  2. Replies: 3
    Last Post: 08-10-2011, 10:17 AM
  3. Replies: 0
    Last Post: 08-07-2011, 09:32 PM
  4. Replies: 0
    Last Post: 02-21-2011, 12:50 PM
  5. Replies: 1
    Last Post: 04-26-2007, 04:52 PM

Posting Permissions

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