java - Using Switch and Try Statement to Validate user Input -


I am working on it for a while and will not compile it. It tells me an error

switch variable option (^) ^ may not have been ^ ^

but I have that variable in the program Set up. So I do not know what the problem is? Is it really something else that is keeping it from the compilation? Import java.io. *; Import javax.swing.JOptionPane; Public Class MyType {Public Static Zero Main (String [] Args) {String Strawwise = "", Stratry String, Strategy Init, Strategy Double; Integer options, tryInt; Repeat the double try; Boolean did = wrong; While (! Done) {try {string reply = joppenpane.shownputdream (empty, "what is my type \ n \ n \ n1) string \ n2) integer \ n3) double \ n4) Skip program"); Choice = integer Parasont (Stroshowice); // Examination for valid code of 1, 2, 3, or 4 (if option & lt; 1; option & gt; 4) New Number Format Suggestions (); Others did = true; } Hold (Number Format Exception E) {JOptionPane.showInputDialog (blank, "Please enter 1, 2, 3, or 4", "Error", JOSEPHEN.INFORMATION_MESSAGE); Switch (Preferred) {Case 1: Javanpanpan. Show Messagidoug (empty, "right, any input can be saved as a string"); break; Case 2: Jobpaction. Show message dialects (empty, "right!"); TryInt = integer Paracetrain (Stroshouis); break; Case 3: Jobpaction. Show Messagidoug (empty, "right!"); TryDouble = integer ParseInt (strChoice); break; Case 4: True = True; Employmentpan Show Messagidoug (empty, "exit".); System.exit (0); break; Default: throwing new number format exceptions; }}}}}}

= "post-text" itemprop = "text">

If showInputDialog throws, then 'likes' is not set. String \ n2) integer \ n3) double \ n4) quit the program ".).

  Try {string reply = joppenpen.showsput dialog (empty," what is my type \ n \ N \ n1); Choice = integer Parasont (Stroshowice); // Examination for valid code of 1, 2, 3, or 4 (if option & lt; 1; option & gt; 4) New Number Format Suggestions (); Others did = true; } Hold (NumberFormatException e) {   

Comments