Re: Can someone determine the output of this?

Discussion in 'Java' started by Lew, Feb 4, 2014.

1. LewGuest

Please embed your question in the body of the post, not just the title.

Question: "Can someone determine the output of this?"

securitygates wrote:
> public class Weather
> {
> public static void main(String [] arguments)
> {
> float fah=86;

Since this is a 'float' expression, you should express the constant as a float.

> System.out.println(fah + "degrees Farenheit is...");
> // To convert Farenheit into Celsius
> // Begin by subtracting 32
> fah = fah-32;
> // Divide the answer by 9
> fah = fah/9;
> // Multiply that answer by 5
> fah = fah*5;
> System.out.println(fah + "degrees Celsius\n");
>
> float cel=33;
> System.out.println(cel + "degrees Celsius is...");
>
> // To convert Farenheit into Celsius
> // Begin by subtracting 32

This is not subtraction of 32:
> cel = cel*9;

> // Divide the answer by 9

This is not division by 9:
> cel = cel/5;

> // Multiply that answer by 5

This is not multiplication by 5:
> cel=cel+32;
> System.out.println(cel + "degrees Farenheit");
> }
> }

Yes.

--
Lew

Lew, Feb 4, 2014