Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » System.out.printf(Need Helps Errors In Project)
icon5.gif  System.out.printf [message #1721808] Sun, 31 January 2016 08:38 Go to next message
Trinh Nguyen is currently offline Trinh NguyenFriend
Messages: 1
Registered: January 2016
Junior Member
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)
Re: System.out.printf [message #1721922 is a reply to message #1721808] Mon, 01 February 2016 16:59 Go to previous message
Russell Bateman is currently offline Russell BatemanFriend
Messages: 3799
Registered: July 2009
Location: Provo, Utah, USA
Senior Member

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.
Previous Topic:Eclipse Mars seems not to use proxy
Next Topic:PHP Website to Android App?
Goto Forum:
  


Current Time: Thu Sep 19 05:23:36 GMT 2019

Powered by FUDForum. Page generated in 0.03128 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top