Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I have been working on this for quite some time. I have the programs running ind

ID: 441158 • Letter: I

Question

I have been working on this for quite some time. I have the programs running individually but have trouble putting them all together in one. Here is the program question Write a Java program that reads an unspecified number of Fahrenheit temperatures, terminating when the user enters 999. The program should determine and output the minimum temperature, maximum temperature, the average temperature, and the number of temperatures above and below freezing. Full Rating to anyone that can show me a program that would fit all of these into one! Please help

Explanation / Answer


//TempStats.java

import java.util.Scanner;

public class TempStats{


public static void main(String[]args)

{

double fahrenheit;

int tempCounts=0,abovefreezing=0,belowfreezing=0;

double sumTemp=0;

double min=999999,max=-999999;

Scanner input=new Scanner(System.in);

do{

System.out.print("Enter a temperature in Fahrenheit(999 to exit): ");

fahrenheit=input.nextInt();

if(fahrenheit!=999){

//min and max

if(fahrenheit<min){min=fahrenheit;}

if(fahrenheit>max){max=fahrenheit;}

//above and below freezing

if(fahrenheit>32){abovefreezing++;}

else if(fahrenheit<32){belowfreezing++;}

//summing

sumTemp+=fahrenheit;

tempCounts++;

}

}while(fahrenheit!=999);

System.out.println(" Temperature Results:");

System.out.printf("Min: %.2f Max: %.2f Average: %.2f ",min,max,sumTemp/(float)tempCounts);

System.out.println("Number of aboving freezing tempertures: "+abovefreezing);

System.out.println("Number of below freezing tempertures: "+belowfreezing);

}//end main

}//end class

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote