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
Step: 1
Java Program import javautil Class definition class DailyTemps Array that holds temperature values p...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Document Format ( 2 attachments)
609343bff12b4_23606.pdf
180 KBs PDF File
609343bff12b4_23606.docx
120 KBs Word File
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started