1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Syntax Error in Java, Eclipse 3.0 (im sure its easy solution)

Discussion in 'Software Development' started by muellerj, Feb 4, 2005.

Thread Status:
Not open for further replies.
  1. muellerj

    muellerj Thread Starter

    Joined:
    Jan 20, 2004
    Messages:
    16
    I am a beginer to Java (im writing my first program for a class) but 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... 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;
    
    
    /**
     * @author MUELLERJ ZABELJJ 
     *
     * TODO To change the template for this generated type comment go to
     * Window - Preferences - Java - Code Style - Code Templates
     */
    public class Convert {
    
    	public static void main(String[] args) {
    		private static double getDouble[COLOR=Red]([/COLOR]string prompt[COLOR=Red]) [/COLOR]{
    	        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.");
    			
    		}
    	}
    }
     
  2. oblivious69

    oblivious69

    Joined:
    Jun 10, 2004
    Messages:
    125
    Not sure if this is the problem, but it should be "String prompt" not "string prompt"...try that.
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/326590

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice