Results 1 to 4 of 4
Thread: Help with my code!
- 08-31-2012, 08:23 PM #1
Member
- Join Date
- Aug 2012
- Posts
- 6
- Rep Power
- 0
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
- 08-31-2012, 09:46 PM #2
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.htmlIf you don't understand my response, don't ignore it, ask a question.
- 08-31-2012, 10:13 PM #3
Member
- Join Date
- Aug 2012
- Posts
- 6
- Rep Power
- 0
Re: Help with my code!
hey thank you very much! it really help me! I appreciate your help
- 09-01-2012, 12:20 AM #4
Re: Help with my code!
Forum Rules - see the third paragraph
Guide For New Members
BB Code List - Java Programming Forum
dbWhy do they call it rush hour when nothing moves? - Robin Williams
Similar Threads
-
I want the source code of DUK's Bank , the example code in Java EE 5 Tutorial 2010
By zahra in forum New To JavaReplies: 16Last Post: 01-31-2012, 08:36 PM -
My code was not executed properly.It will jumping to exception handling.my code is
By vinay4051 in forum EclipseReplies: 3Last Post: 08-10-2011, 09:17 AM -
servlet include method copying sorce code and executing source code as output how to
By shamkuma2k in forum Advanced JavaReplies: 0Last Post: 08-07-2011, 08:32 PM -
C server code - Java CLient Code _ TCP Connection Problem
By rmd22 in forum NetworkingReplies: 0Last Post: 02-21-2011, 11:50 AM -
Generating Code Automatically Using Custom code Template In Eclipse
By JavaForums in forum EclipseReplies: 1Last Post: 04-26-2007, 03:52 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks