|
Re: System.out.printf [message #1721922 is a reply to message #1721808] |
Mon, 01 February 2016 16:59 |
|
On 02/01/2016 05:46 AM, Trinh Nguyen wrote:
> Hello everyone,
> I just started using Eclipse for my class. I have a problem while trying
> to do my assignment for my JAVA class and I can't seem to find the
> answer for it. Does anybody know what's the problem with my project.
> Assignment: The formula for converting centigrade temperature to
> Fahrenheit is:
> F = 32 + C (180.0/100.0)
> Write a program that asks the user to enter a temperature reading in
> Centigrade and then prints the equivalent Fahrenheit value. It then asks
> the user to enter a Fahrenheit value and prints out the equivalent
> Centigrade value. Run the program several times. Be sure to include at
> least one negative temperature reading in your test cases.
>
> import java.util.Scanner;
> public class Lab3Proj2 {
>
> public static void main(String[] args) {
> int C = 4;
> Scanner a1 = new Scanner(System.in);
> System.out.println("Enter a temperature reading in Centigrade: ");
> C = a1.nextInt();
>
> float F = 0.0f;
> F = (32 + C (180.0/100.0));
> System.out.println("The equivalent Fahrenheit value is:" + F);
>
>
> Output:
> Exception in thread "main" java.lang.Error: Unresolved compilation
> problem: The method C(double) is undefined for the type Lab3Proj2
>
> at Lab3Proj2.main(Lab3Proj2.java:11)
>
This is a Java problem and nothing to do with Eclipse. You should get
help in a more Java forum like javaranch.com, jguru.com or a
general-purpose programming forum like stackoverflow.com.
On your way there, however, your code isn't proper Java, in particular,
the line:
F = (32 + C (180.0/100.0));
To the compiler, it would appear that C is a method (whereas you've
defined it earlier to be an integer variable, which is what it is).
Since there is no method C( double ), the compiler is telling you.
Best of luck.
|
|
|
Powered by
FUDForum. Page generated in 0.08747 seconds