Because I am Stuck. (if you can't tell form the presence of the UNIX thread I am NOT haing a good time. My file won't compile andthe error I get is Code: Calc.java:28: incompatible types found : double required: java.lang.Double radius = Double.parseDouble (inputLine); ^ Calc.java:29: operator * cannot be applied to double,java.lang.Double volume = 4 / 3 * Math.PI * radius *radius * radius; ^ Calc.java:30: operator * cannot be applied to double,java.lang.Double surfaceArea = 4 * Math.PI * radius * radius; ^ inputLine is a string and radius is a floating point number. I am trying to convert text input to a number to calculate the surface area an volume of a sphere hen output the results
What kind of text do you want to convert? I have yet to see a reasonable string -> int/double conversion.
The program needs to convert whatever number I type in into a floating point number in order to use it in calculations This is the prompt we were given: Nevermind. I feel so stupid now. I capitalized the statements that create the variables I do have a questin though. When i did the formula for Volume ha to put the 4/3 at the end of the expression to get the right results. How come Code: 4 / 3 * Math.PI * radus* radius * radius prints out erroneous numbers while Code: Math.PI * radus* radius * radius * 4 / 3 give the right answer and how do I make them both do the same thing
You should use 4.0 and/or 3.0 for the 4/3 part. Integer division is going to give you a wrong answer.