| | |
Whats wrong with this code?
![]() |
Howdy, Im getting the "'.class expected" error and I dont know what to correct. The code is
Thanks
-Airman
Java Syntax (Toggle Plain Text)
import java.io.*; public class TeamHeight { public static void main (String[] args) throws IOException { double[] height = new double[11]; double sum = 0; System.out.println ("The size of the array: " + height.length); for (int i = 0; i < height.length; i++) { BufferedReader keyIn = new BufferedReader (new InputStreamReader(System.in)); System.out.print ("Enter the height of the player: "); height = Double.parsedouble[](keyIn.readLine()); System.out.print ("Player " + (i+1) + ": "); height[i] = Integer.parseInt(keyIn.readLine()); sum = sum + height[i]; } System.out.println ("The average height: " + (sum/11)); System.out.println (); } }
Thanks
-Airman
Have you compiled the code? That error usually relates to attempting to run a main method in a file that has not yet been compiled. If that was a compiler error, which line(s) give the error?
There are no stupid questions, only those too stupid to ask for help.
echo is a web developer's best friend. •
•
•
•
Have you compiled the code? That error usually relates to attempting to run a main method in a file that has not yet been compiled. If that was a compiler error, which line(s) give the error?
The error is at the line:
BufferedReader keyIn = new BufferedReader (new InputStreamReader(System.in));
System.out.print ("Enter the height of the player: ");
height = Double.parsedouble[](keyIn.readLine());
•
•
Join Date: Jun 2007
Posts: 59
Reputation:
Solved Threads: 3
I mean:
an then:
Java Syntax (Toggle Plain Text)
double temp = Double.parseDouble(keyIn.readLine());
an then:
Java Syntax (Toggle Plain Text)
height[i] = temp;
Last edited by Chaster; Aug 14th, 2008 at 6:27 am.
•
•
Join Date: Jun 2007
Posts: 59
Reputation:
Solved Threads: 3
That's because height is an ARRAY but you here need a PRIMITIVE. You can use either a temp variable (as I described earlier), or try this: height[i] = Double.parseDouble(...);
Last edited by Chaster; Aug 14th, 2008 at 9:15 am.
![]() |
Similar Threads
- Please help me i dont understand whats wrong with my code (C++)
- Please help me figure out whats wrong with my code (C++)
- whats wrong with my code cant display result (C)
- Whats wrong with this class??? (C++)
- Whats wrong with this code (PHP)
- Hello Everyone, I need Help with my C++ Code... (C++)
Other Threads in the Java Forum
- Previous Thread: Please help Errors will not compile
- Next Thread: Adding images to JAR file (Netbean 5.0)
| Thread Tools | Search this Thread |
911 addball addressbook android api append applet application apps array arrays automation binary bluetooth businessintelligence button card chat class client code collision component crashcourse css csv database eclipse ee error fractal free game gis givemetehcodez graphics gui html ide image input integer integration j2me japplet java javaarraylist javadoc javafx javaprojects jni jpanel julia jvm linux list loan loop machine map method methods migrate mobile netbeans newbie objects oriented output panel phone physics problem program programming project radio recursion reporting scanner se server service set sms socket software sort sql string swing test textfield threads transfer tree trolltech ubuntu utility windows





