Results 1 to 5 of 5
Thread: Need help to solve my problem
 08192009, 10:19 AM #1Member
 Join Date
 Aug 2009
 Posts
 6
 Rep Power
 0
Need help to solve my problem
What is the wrong with my program
need help!
Java Code:import javax.swing.*; import java.text.DecimalFormat; public class MyMenuCS { public static void main (String[] args) { String ch; int n; int choice; for(n=JOptionPane.showConfirmDialog(null,"Do you want to continue","Really Quit",JOptionPane.YES_NO_OPTION); ch=JOptionPane.showInputDialog(" MENU OF OPERATIONS\n\n"+ " [1] Addition\n" + " [2] Subtraction\n" + " [3] Multiplication\n" + " [4] Division\n" + " [0] Quit\n\n" + "Enter your choice: "); choice=Integer.parseInt(ch); [COLOR="red"][B]<')' expected[/B][/COLOR] switch(choice) { case 1: JOptionPane.showMessageDialog(null,"Addition is selected."); String in1,in2; int a,b,sum; in1=JOptionPane.showInputDialog("Enter The First Number:"); in2=JOptionPane.showInputDialog("Enter The Second Number:"); a=Integer.parseInt(in1); b=Integer.parseInt(in2); sum=a+b; JOptionPane.showMessageDialog(null,"The sum is:"+sum); System.exit(0); break; case 2: JOptionPane.showMessageDialog(null,"Subtraction is selected."); break; case 3: JOptionPane.showMessageDialog(null,"Multiplication is selected."); break; case 4: JOptionPane.showMessageDialog(null,"Division is selected."); break; case 0: break; default: JOptionPane.showMessageDialog(null,"ERROR: Invalid choice.","Error Message",JOptionPane.ERROR_MESSAGE); break; }//switch }//for System.exit(0); [COLOR="Red"][B] <<identifier> expected[/B][/COLOR] }//main }//class [COLOR="red"][B]<'class' or 'interface' expected[/B][/COLOR]
 08192009, 05:51 PM #2
 Join Date
 Jul 2007
 Location
 Colombo, Sri Lanka
 Posts
 11,370
 Blog Entries
 1
 Rep Power
 23
Java Code:for(n=JOptionPane.showConfirmDialog(null,"Do you want to continue","Really Quit",JOptionPane.YES_NO_OPTION);
 08202009, 04:00 PM #3Member
 Join Date
 Aug 2009
 Posts
 6
 Rep Power
 0
Sir Im Just Asking for the correct applying
for
plss help

It's hard to know how to help as this code is completely futzed. I'm afraid that you can't make up methods and your own strange loops and expect them magically to work. If you want to create a for loop, I suggest that you have a look here at the tutorial on them: The for Statement
 08212009, 04:26 AM #5
 Join Date
 Jul 2007
 Location
 Colombo, Sri Lanka
 Posts
 11,370
 Blog Entries
 1
 Rep Power
 23
Yes, actually your for loop is totally incorrect. So first of all you must correct that. Fubarable send a nice link to you in his post. Then you've to explain your requirement more clearly, if you really need our help. At the same time, keep in mind that you've to put some effort as well.
Similar Threads

Could someone help me to solve this problem...
By Vinny in forum Java SoftwareReplies: 1Last Post: 07082009, 06:59 PM 
Factory problem: How to Solve it
By rahul_capricorn in forum Threads and SynchronizationReplies: 2Last Post: 02112009, 04:47 PM 
Help me to solve problem
By mansoorhacker in forum Forum GuidesReplies: 8Last Post: 01242009, 06:29 PM 
Solve my Problem
By kyo in forum New To JavaReplies: 1Last Post: 12162008, 02:22 PM 
Help me to solve problem
By mansoorhacker in forum New To JavaReplies: 3Last Post: 11132008, 08:15 AM
Bookmarks