Jump to content


Covertion


  • Please log in to reply
3 replies to this topic

#1 genako

genako

    Newbie

  • Members
  • Pip
  • 3 posts
  • Gender:Female

Posted 29 June 2011 - 02:28 AM

write a program that will converts a temperature from degrees fahrenhiet to degrees celcius the formula for converting the temperature from degrees fahrenhiet to degrees celcius is c= (5/9)*(F-32)
display both degrees fahrenhiet and degrees celcius.
i dont know what is the problem.
here is my code does not function
import java.util.*;
public class convert {
    static Scanner console = new console(Sytem.in);
    public static void main(String[] args); {
  
    float celsius;
    float fahrenheit;
  
    
     System.out.println("Enter  temperature.");
     celsius = console.nextDouble((5/9)*(fahrenheit-32));
     System.out.println("fahrenheit + "degrees Fahrenheit" * celsius + "degrees Celsius.");
    
}
}

#2 Blackiey

Blackiey

    Newbie

  • Members
  • Pip
  • 6 posts

Posted 21 November 2011 - 04:19 AM

import java.util.*;
public class convert
{
	 static Scanner console = new console(Sytem.in);
	 public static void main(String[] args);
	 {
		  float celsius;
		  float fahrenheit;

		  System.out.println("Enter temperature.");
		  celsius = console.nextDouble((5/9)*(fahrenheit-32));
		  System.out.println("fahrenheit + "degrees Fahrenheit" * celsius + "degrees Celsius.");
	 }//end of main
}//end of class


#3 Blackiey

Blackiey

    Newbie

  • Members
  • Pip
  • 6 posts

Posted 21 November 2011 - 04:22 AM

Its
Scanner console = new Scanner(System.in);

not
static Scanner console = new console(System.in);

/type /name = new /type;

#4 joankim

joankim

    Newbie

  • Members
  • Pip
  • 5 posts

Posted 19 December 2011 - 09:51 PM

Okay, first off, I'd use double instead of float. Also, you should try this:
System.out.println("Enter temperature in fahrenheit");
fahrenheit = console.nextDouble;
celcius = (celcuis*(5/9))*(fahrenheit-32);

instead of
System.out.println("Enter temperature.");
celsius = console.nextDouble((5/9)*(fahrenheit-32));

also, your s.o.p. line is wrong. It should look like this:
System.out.println("fahrenheit + " degrees Fahrenheit equals to " + celsius + "degrees Celsius.");

Also, I thought degree consersion from fahrenheit to celsius was: multiply by 5 over nine, and then subract 32
Or is my memory bad?