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

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

Step by Step Solution

3.40 Rating (150 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

To implement the DailyTemps Java class that captures daily temperatures for a week and provides various methods to interact with this data follow these steps Step 1 Define the Class and Initialize the ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Document Format (2 attachments)

PDF file Icon

609343bff12b4_23606.pdf

180 KBs PDF File

Word file Icon

609343bff12b4_23606.docx

120 KBs Word File

Students Have Also Explored These Related Programming Questions!