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 Mondays temperature; array index 1 represents Tuesdays temperature; etc

Part 1 (40 points): Write class DailyTemps with the following methods:

(5 points) 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.

(5 points) 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.

(10 points) Method Freezing() that returns the number of days with temperature below freezing (under 32F) for the week.

(10 points) Method Warmest() that returns the index of the warmest day in the week.

(10 points) 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

. . .

Part 2 (10 points): Write a test program, TestDailyTemps, to create an object of class DailyTemps and test all of the class methods on that object. Use proper prompts labels for displaying outputs.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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

Students Have Also Explored These Related Databases Questions!