I need to make a table of Celsius to Fahrenheit conversions. The output should be exactly like this:
-40.0C is -40.0F -30.0C is -22.0F -20.0C is -4.0F -10.0C is 14.0F
-39.0C is -38.2F -29.0C is -20.2F -19.0C is -2.2F -9.0C is 15.8F
-38.0C is -36.4F -28.0C is -18.4F -18.0C is -0.4F -8.0C is 17.6F
-37.0C is -34.6F -27.0C is -16.6F -17.0C is 1.4F -7.0C is 19.4F
-36.0C is -32.8F -26.0C is -14.8F -16.0C is 3.2F -6.0C is 21.2F
-35.0C is -31.0F -25.0C is -13.0F -15.0C is 5.0F -5.0C is 23.0F
-34.0C is -29.2F -24.0C is -11.2F -14.0C is 6.8F -4.0C is 24.8F
-33.0C is -27.4F -23.0C is -9.4F -13.0C is 8.6F -3.0C is 26.6F
-32.0C is -25.6F -22.0C is -7.6F -12.0C is 10.4F -2.0C is 28.4F
-31.0C is -23.8F -21.0C is -5.8F -11.0C is 12.2F -1.0C is 30.2F
The trick is, you can only use one while loop for the whole thing. Also you can't just type everything as it is. I am strugling to figure out a way for how to start a new column each time it goes through the 10 conversions or something of that type, i made a program that works but its lame and kinda cheating:
public class TempConvWorking{
public static void main (String[] args){
double celsius1 = -40.0, celsius2 = -30.0, celsius3 = -20.0, celsius4 = -10.0;
double fahreheit1, fahreheit2, fahreheit3, fahreheit4;
while (celsius4 < 0){
fahreheit1 = (celsius1 * (1.8) + 32.0);
fahreheit2 = (celsius2 * (1.8) + 32.0);
fahreheit3 = (celsius3 * (1.8) + 32.0);
fahreheit4 = (celsius4 * (1.8) + 32.0);
System.out.printf ("%.1fC is %.1fF\t%.1fC is %.1fF\t%.1fC is %.1fF\t%.1fC is %.1fF\t\n",celsius1,fahreheit1,celsius2,fahreheit2,celsius3,fahreheit3,celsius4,fahreheit4);
celsius1 += 1;
celsius2 += 1;
celsius3 += 1;
celsius4 += 1;
}
}
}
so if anyone has suggestions please explain.