View Single Post
  #1 (permalink)  
Old 07-31-2007, 10:40 PM
baltimore baltimore is offline
Member
 
Join Date: Jul 2007
Posts: 40
baltimore is on a distinguished road
Syntax error on token "(", ; expected
Hi, I can't seem to figure out a syntax error. Here is some stuff for background. I am using Eclipse 3.0.1 IDE and I downloaded Java 5 Update 1 JDK from Sun and installed both (note I installed Eclipse first, not sure if it matters). Windows XP SP2.

Eclipse is showing this error...
Code:
Syntax error on token "(", ; expected Syntax error on token ")", ; expected
for the following code.(line 21)

The IDE underlines the () that I put in RED and says the error is there. I don't get it because I don't think I need a ; anywhere. (and this code is copied directly from my prof's website)

Thanks for any help, really really new to java, I hope it is something simple.

Code:
package edu.uwec.cs.muellerzabel.conversion; import javax.swing.JOptionPane; public class Convert { public static void main(String[] args) { private static double getDouble(string prompt) { double x = 0; boolean done = false; while (!done) { try { x = Double.parseDouble(JOptionPane.showInputDialog(prompt)); done = true; } catch (NumberFormatException e) { JOptionPane.showMessageDialog(null, "That wasn't a valid input. Please enter a number."); } } return x; } double dblUserInput = 0; double dblEnglish = 0; double dblFeet = 0; double dblInches = 0; dblUserInput = getDouble("Enter the number of meters you would like to convert to feet or inches."); dblEnglish = dblUserInput * 39.37; dblFeet = dblEnglish / 12; dblInches = dblEnglish; if (dblEnglish > 12){ JOptionPane.showMessageDialog(null, dblUserInput + " meters is equal to " + dblFeet + " feet."); }else { JOptionPane.showMessageDialog(null, dblUserInput + " meters is equal to " + dblInches + " inches."); } } }
Thanks.
Reply With Quote
Sponsored Links