Hourly Temperature

  • Uploaded by: david johnson
  • 0
  • 0
  • November 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Hourly Temperature as PDF for free.

More details

  • Words: 232
  • Pages: 2
Hourly Temperature /* * Main.java * * Created on September 27, 2007, 4:43 PM * * To change this template, choose Tools | Template Manager * and open the template in the editor. */ package hourlytemperature; /** * * @author instructor */ public class Main { /** Creates a new instance of Main */ public Main() { } /** * @param args the command line arguments */ public static void main(String[] args) { // define variables double currentTemp = 0; double totalTemp = 0; double maxTemp = 0; double minTemp = 0; int maxHour = 0; int minHour = 0; //start the loop for(int hours = 0; hours<24; hours++) { System.out.println("Please enter the current temperature at this hour: "); currentTemp = MyInput.readDouble(); totalTemp = totalTemp + currentTemp; if(hours == 0) { maxTemp = currentTemp; minTemp = currentTemp;

} else { if(currentTemp > maxTemp) { maxTemp = currentTemp; maxHour = hours; }//end if statement if(currentTemp < minTemp) { minTemp = currentTemp; minHour = hours; }//end if statement }//end if else stetement }//end for loop //calculate average temp double averageTemp = totalTemp / 24; //display results System.out.println("The max temp is "+ maxTemp +" degrees happened at the hour of "+maxHour); System.out.println("The min temp is "+ minTemp +" degrees happened at the hour of "+minHour); System.out.println("The average temp during the 24 hour period is: " + averageTemp); }//end of main() method }//end of Main class

Related Documents

Hourly Temperature
November 2019 21
Temperature
November 2019 25
Temperature
May 2020 14
Temperature
April 2020 25
Hourly Salary Survey 2006
October 2019 19

More Documents from "Adriel Casongsong"

Syll_fall_2008
November 2019 17
Acct 101 Syllabus
November 2019 27
Classex For Loop
November 2019 24
Jake S Client And Pet Data
November 2019 20
Mortgage Table
November 2019 18