Find the minimum temperature

Assignment Help JAVA Programming
Reference no: EM131914299

You need a variable that will keep track of the maximum of the values processed so far. This variable must be initialized before the loop. There are two standard techniques for initialization: one is to initialize the variable to some value smaller than any possible value being processed; another is to initialize the variable to the first value processed. In either case, after the first value is processed the maximum variable should contain the first value. For the temperature program declare a variable maxTemp to hold the maximum temperature we need to Initialize it to -1000 (a value less than any legitimate temperature).

The maximum variable must be updated each time through the loop. This is done by comparing the maximum to the current value being processed. If the current value is larger, then the current value is the new maximum. So, in the temperature program, add an if statement inside the loop to compare the current temperature read in to maxTemp. If the current temperature is larger set maxTemp to that temperature. and : If the current temperature is NOT larger, DO NOTHING!

also need to Add code to print out the maximum after the loop.

want to keep track of the time (hour) the maximum temperature occurred. save the current value of the hour variable when update the maxTemp variable. This of course requires a new variable to store the time (hour) that the maximum occurs. Declare timeOfMax (type int) to keep track of the time (hour) the maximum temperature occurred. Modify if statment so that in addition to updating maxTemp you also save the value of hour in the timeOfMax variable. (WARNING: you are now doing TWO things when the if condition is TRUE.)

need to print out the time the maximum temperature occurred along with the maximum.

also need to add code to find the minimum temperature and the time that temperature occurs. The idea is the same as for the maximum. need a separate if when updating the minimum temperature variable (that is, don't add an else clause to the if that is already there).

// Temps.java

//

// This program reads in a sequence of hourly temperature

// readings (beginning with midnight) and prints the maximum

// temperature (along with the hour, on a 24-hour clock, it

// occurred) and the minimum temperature (along with the hour

// it occurred).

// **********************************************************


import java.util.Scanner;


public class Temps

{

//----------------------------------------------------

// Reads in a sequence of temperatures and finds the

// maximum and minimum read in.

//----------------------------------------------------

public static void main (String[] args)

{

final int HOURS_PER_DAY = 24;


int temp; // a temperature reading


Scanner scan = new Scanner(System.in);


// print program heading

System.out.println ();

System.out.println ("Temperature Readings for 24 Hour Period");

System.out.println ();


for (int hour = 0; hour < HOURS_PER_DAY; hour++)

{

System.out.print ("Enter the temperature reading at " + hour +

" hours: ");

temp = scan.nextInt();

}


// Print the results

}

}

Reference no: EM131914299

Questions Cloud

Does the observed data contradict the company claim : Does the observed data contradict the company's claim? Formulate and test the appropriate hypotheses at the 2.5% level of significance.
How immigrants are absorbed into a new culture : Write an essay that details how immigrants are absorbed into a new culture. In your essay, address how the racial and/or ethnic composition of an immigrant.
What is the p-value for the appropriate test : He picks an SRS of 30 recruits and calculates their mean 5K time is 16 minutes 52 seconds, with a standard deviation of 25 seconds.
Discuss the characteristics of persuasive writing : Apply the characteristics of persuasive writing to turn the Literature Review into a persuasive argument. The persuasive argument begins with a strong hook.
Find the minimum temperature : find the minimum temperature and the time that temperature occurs. The idea is the same as for the maximum. need a separate if when updating the minimum
What amount of the travel costs can melissa deduct as busine : Suppose that while Melissa was on the coast, she also spent two days sightseeing. What amount of the travel costs can Melissa deduct as business expenses?
Different nonzero digits followed by three different letters : If each licence plate contains three different nonzero digits followed by three different letters
How does brison define pornography : What does Mill say is "assumed" by the person who wishes to suppress an opinion because they are sure it is false?
Distribution function for the random variable : Suppose that the random variable X has a geometric distribution with a mean of 2.5. Determine the following probabilities:

Reviews

Write a Review

JAVA Programming Questions & Answers

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd