Use a for or while loop in Java to display a Celsius to Fahr

Use a for or while loop in Java to display a Celsius to Fahrenheit Table begin with 0C

Example maximum Celsius temperature to display is 22C at 5C increments

Celsius Fahrenheit

0 32

5 41

10 50

15 59

20 68

Solution

CelsiusConvertion.java


public class CelsiusConvertion {

   public static void main(String[] args) {
       System.out.println(\"Celsius\\tFahrenheit\");
       int celsius, fahrenheit;
       for(celsius=0; celsius<=20; celsius+=5){
           fahrenheit = celsius*(9/5) + 32;
           System.out.println(celsius+\"\\t\"+fahrenheit);
       }
   }

}

OUtput:

Celsius   Fahrenheit
0   32
5   37
10   42
15   47
20   52

Use a for or while loop in Java to display a Celsius to Fahrenheit Table begin with 0C Example maximum Celsius temperature to display is 22C at 5C increments Ce

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site