Results 1 to 7 of 7
- 08-29-2011, 03:02 PM #1
Member
- Join Date
- Apr 2010
- Posts
- 34
- Rep Power
- 0
joptionpane quizz , improve my code ....
i want to make kind of quizz with joption pane,
can someone give me tips , how to improve my code??
Java Code:import javax.swing.JOptionPane; public class Main { public static void main(String[] args) { String no = null; no = JOptionPane.showInputDialog("sum of 229+566="); if ( no == null ? "sum" == null : no.equals("795")) { JOptionPane.showMessageDialog(null, "correct " + no); } else {JOptionPane.showMessageDialog(null, "wrong " + no);} String nom = null; nom = JOptionPane.showInputDialog("mul of 229x566="); if ( nom == null ? "sum" == null : nom.equals("129614")) { JOptionPane.showMessageDialog(null, "correct " + nom); } else {JOptionPane.showMessageDialog(null, "wrong " + nom);} }
- 08-29-2011, 03:09 PM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,605
- Blog Entries
- 7
- Rep Power
- 17
Does your code work as you want it to work? Yes? There's a saying: "if it ain't broke, don't fix it".
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
- 08-29-2011, 03:48 PM #3
Member
- Join Date
- Apr 2010
- Posts
- 34
- Rep Power
- 0
it is working, but i want to put 50 questions , so i have to do this all the time!
there is no better way i can fix it???
- 08-29-2011, 03:50 PM #4
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,605
- Blog Entries
- 7
- Rep Power
- 17
- 08-29-2011, 03:57 PM #5
Member
- Join Date
- Apr 2010
- Posts
- 34
- Rep Power
- 0
can u please give a quick example ??
many thanks
- 08-29-2011, 04:45 PM #6
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,605
- Blog Entries
- 7
- Rep Power
- 17
Sure, this is a quick example:
Because it's spoonfeeding, you have to figure out its details.Java Code:boolean sumQuestion(int x, int y) { return (""+(x+y)).equals(JOptionPane.showInputDialog("sum of "+x+"+"+y+"="); }
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
- 08-30-2011, 01:04 AM #7
Similar Threads
-
What can i do to improve this? Explanation please
By biggerthanblue in forum New To JavaReplies: 1Last Post: 02-19-2011, 06:55 AM -
Improve my GUI!
By AJArmstron@aol.com in forum New To JavaReplies: 8Last Post: 04-27-2010, 09:17 PM -
How to improve this code
By Raymond in forum Advanced JavaReplies: 9Last Post: 03-19-2010, 08:16 AM -
how to improve my security?
By anthrax in forum JavaServer Pages (JSP) and JSTLReplies: 1Last Post: 03-13-2009, 09:08 AM -
trying to improve code to avoid java.lang.OutOfMemory error
By bdyarem in forum New To JavaReplies: 16Last Post: 08-05-2008, 11:34 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks