Menu
Topics Index
...
`

Print min max and average temperatures with out using methods - Java Example Program


Print min max and average temperatures with out using methods
class PrintMinMaxAndAvgTemperatures
{
    public static void main(String arg[])
    {
        double min_temp_in_F = 75.86;
        double max_temp_in_F = 105.72;
        
        double avg_temp_in_F = ( min_temp_in_F + max_temp_in_F ) / 2.0;
        
        double min_temp_in_C = ( min_temp_in_F - 32.0 ) * 5.0 / 9.0;
        double max_temp_in_C = ( max_temp_in_F - 32.0 ) * 5.0 / 9.0;
        double avg_temp_in_C = ( avg_temp_in_F - 32.0 ) * 5.0 / 9.0;
        
        
        System.out.println("Min temp in F = " + min_temp_in_F + ", in C = " + min_temp_in_C);
        System.out.println("Max temp in F = " + max_temp_in_F + ", in C = " + max_temp_in_C);
        System.out.println("Avg temp in F = " + avg_temp_in_F + ", in C = " + avg_temp_in_C);
    
    }
}
OUTPUT

Min temp in F = 75.86, in C = 24.366666666666667
Max temp in F = 105.72, in C = 40.955555555555556
Avg temp in F = 90.78999999999999, in C = 32.661111111111104

DESCRIPTION

© meritcampus 2019

All Rights Reserved.

Open In App