Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Use the Scanner class to code this program. Submit only your source code file ( i . e . , the class you create and
Use the Scanner class to code this program.
Submit only your source code file ie the class you create and the Demo program Note: a class file you do not create is automatically generated when you run a program. Do not submit this class file.
This exam covers concepts in Chapters only. The use of code not covered in Chapters will result in a major error per instance which could cause you to fail the exam.
Submission Instructions
Upload two separate files to Brightspace: a Weather.java file and a Demo.java file. Do not zip your files together or change the name of the files. Do not submit a jGrasp project file. Do not submit a GitHub link. Failure to follow these directions exactly will result in a point deduction.
Program Description
A local weather station has tasked you with building a small application that displays daily sky conditions along with the associated high temperatures in degrees of Celsius, Fahrenheit and Kelvin. Write a program that prompts the user for the number of days they wish to include in the weather report, inputs daily sky conditions & high temperatures in Celsius, and uses that data to display a weather report See Sample Output
Program Requirements
The weather report must include at least one day, but no more than seven days. Your program should not allow the user to enter data until a valid number of days has been entered. It should also handle input like that shown in the Sample Input.
For each day, your program must track the sky condition and the high temperature in Celsius. There are four types of sky conditions: Sunny, Cloudy, Rainy, and Snowy. Your program must use a menu to prompt the user for the sky condition. The program must validate the menu choice to only accept a valid sky condition.
Valid high temperature input depends upon the sky condition. For Sunny, Cloudy and Rainy conditions, a valid Celsius temperature is greater than degrees and no higher than degrees. For Snowy days, a valid Celsius temperature is no lower than degrees and no higher than degrees.
Input Validation Requirements
Users must have an unlimited number of chances to enter valid data.
Validation method must be as efficient as possible. See textbook for examples.
Once all the data has been entered and validated, the program should display a weather report See Sample Output Following the listing of all the daily conditions, the program must display: the number of days in the weather report, the average of all the Celsius temperatures in the report, the average of all the Fahrenheit temperatures in the report and the average of all the Kelvin temperatures in the report.
Design Requirements
You must design a fully objectoriented program that avoids stale data using basic objectoriented concepts. The program should prompt the user for all the data necessary to fully initialize the objects. Initialization should be done as efficiently as possible. In addition to basic objectoriented concepts, your program must store the appropriate objects in a container that automatically expands as more objects are added to it
Create a class named Weather that contains the data the class must store, getters, setters, constructors both arg and noarg and the following methods:
a method that accepts no arguments and calculates and returns the Fahrenheit temperature based on the Celsius temperature using the following formula:
Fahrenheit Temperature Celsius Temperature
a method that accepts no arguments and calculates and returns the Kelvin temperature based on the Celsius temperature using the following formula: Kelvin Temperature Celsius Temperature
a method that accepts no arguments and only displays the sky condition and high temperatures in Celsius, Fahrenheit and Kelvin formatted as shown in the Sample Output.
Create a class named Demo that uses Weather objects and implements all the program and design requirements. Your programs output must exactly match the Sample Output including white space, indention, and blank lines.
Sample Output user input is shown in bold
Enter the number of days in the Weather Report:
ERROR: INVALID NUMBER OF DAYS ENTERED. TRY AGAIN.
Enter the number of days in the Weather Report:
ERROR: INVALID NUMBER OF DAYS ENTERED. TRY AGAIN.
Enter the number of days in the Weather Report:
Enter the weather conditions for Day :
A Sunny
B Cloudy
C Rainy
D Snowy
Enter your choice A B C or D: F
ERROR: INVALID CHOICE. Please try again.
Enter the weather conditions for Day :
A Sunny
B Cloudy
C Rainy
D Snowy
Enter your choice A B C or D: B
Enter the high Celsius temperature for Day :
ERROR: INVALID HIGH TEMPERATURE ENTERED. Please try again.
Enter the high Celsius temperature
Step by Step Solution
There are 3 Steps involved in it
Step: 1
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
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started