-
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
-
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
-
Re: Help with my code!
hey thank you very much! it really help me! I appreciate your help
-
Re: Help with my code!