Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial


Temperature Conversion

Write a program that converts degrees from Fahrenheit to Celsius, using the formula DegreesC = 5 (DegreesF − 32) / 9. Prompt the user to enter a temperature in degrees Fahrenheit as a whole number without a fractional part. Then have the program display the equivalent Celsius temperature, including the fractional part to at least one decimal point.

1 Answer

import java.util.Scanner;

public class Example{

 public static void main(String[] args){

   Scanner input = new Scanner(System.in);

     double c = 0;
     double f =0;
     System.out.println("Enter degrees in Fahrenheit: ");
     f = input.nextInt(); 

     c = (f-32)/9;

     System.out.printf("The temperature in Celsius is: %.2f",c);


This should get you in right direction.