Write a Java class that implements the concept of Daily Temperatures for a week. The class has
Question:
Write a Java class that implements the concept of Daily Temperatures for a week. The class has only one attribute (data field): a single dimensional array of integers of size 7 elements to hold daily temperatures. Assume that array index 0 represents Monday’s temperature; array index 1 represents Tuesday’s temperature; etc…
Part 1: Write class DailyTemps with the following methods:
A constructor that creates the array and populates the array with user inputs (temperature values for the week). Use proper prompts for reading the inputs.
Method setTemp(…) that allows re-setting the temperature for one day (one value in the array). The day is specified by the array index of its position in the array.
Method Freezing () that returns the number of days with temperature below freezing (under 32F) for the week.
Method Warmest () that returns the index of the warmest day in the week.
Method toString to print out the temperatures for the week (each line displays the day name followed by its temperature reading). For example,
Monday……………….57
Tuesday……………….76
Wednesday……………81
Data Structures and Algorithms in Java
ISBN: 978-1118771334
6th edition
Authors: Michael T. Goodrich, Roberto Tamassia, Michael H. Goldwasser