How to make that before plus Celsius values, was output plus sign, cons are automatically add to minus value. This is methods which calculate the value. Or maybe i need to use some output modification?
public static double CtoF(double Celsius) {
System.out.println("Celsius | Fahrenheit");
System.out.println("");
for (int i = 0; i <= 50; i++) {
Celsius = (Celsius*9/5)+32;
System.out.printf("%3d | ", i);
System.out.println((int) Celsius);
}
return Celsius;
}
public static double FtoC(double Fahrenheit) {
System.out.println("Fahrenheit | Celsius");
System.out.println("");
for (int i = 0; i <= 50; i++) {
Fahrenheit = (Fahrenheit-32)*5/9;
System.out.printf("%3d | ", i);
System.out.println((int) Fahrenheit);
}
return Fahrenheit;
}
Output of values:
Celsius | Fahrenheit
0 | 32
1 | 89
2 | 193
3 | 379
4 | 715
5 | 1320
6 | 2408
7 | 4367
8 | 7894
9 | 14241
10 | 25667
Fahrenheit | Celsius
0 | -17
1 | -27
2 | -33
3 | -36
4 | -37
5 | -38
6 | -39
7 | -39
8 | -39
9 | -39
10 | -39
UPD: Here is answer: Format a number with leading sign