# Celsius to fahrenheit vice versa

• September 15th, 2013, 10:25 AM
Onlyname
Celsius to fahrenheit vice versa
Hello again guys,

I am having some trouble here not sure what is going on. I have gotten my program to show Celsius to Fahrenheit. However, it is not showing Fahrenheit to Celsius. I am trying to put it into chart form as well.

Below is code:

Code java:

``` public static void main(String[] args) { java.util.Scanner input = new java.util.Scanner(System.in); System.out.println(" ");         for (double i = 31; i < 41; i++) { System.out.println("Celcius: " + i + " is " + celsiusToFahrenheit(i) + " in Fahrenheit"); }   for (double f = 120; f < 104; f++){ System.out.println("Fahrenheit: " + f + " is " + fahrenheitToCelsius(f) + " in Celsius");} }         public static double celsiusToFahrenheit(double i) { return (9.0 / 5) * i +32; }   public static double fahrenheitToCelsius(double f) { return (5.0 / 9) * f - 32; }       }```
• September 15th, 2013, 01:18 PM
GregBrannon
Re: Celsius to fahrenheit vice versa

for (double f = 120; f < 104; f++)
• September 16th, 2013, 03:48 PM
Onlyname
Re: Celsius to fahrenheit vice versa
Dont think I was.

I now have

for (double f = 120; f < 30; f++)

Regardless, it isn't even printing out...
• September 16th, 2013, 03:56 PM
GregBrannon
Re: Celsius to fahrenheit vice versa
You haven't thought enough about that for statement, the old or the new. When will f be less than 104 or less than 30. Maybe . . . . . I know, NEVER.
• September 16th, 2013, 04:08 PM
Onlyname
Re: Celsius to fahrenheit vice versa
haha.... wow, well thank you.

I think I should have it from here.

As usual thanks for your help.

--- Update ---

Actually while I have you here, how do I separate them in chart form

Celsius Fahrenheit | Fahrenheit Celsius
-----------------------------------------------

x x x x

I am getting the results I want and I have the top bar of the chart setup. I just do not know how to align the Fahrenheit into Celsius(right side)
• September 16th, 2013, 11:39 PM
Junky
Re: Celsius to fahrenheit vice versa
To format output you can use the String.format method or the printf method.