Answered step by step
Verified Expert Solution
Link Copied!

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 (i.e., 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 1-7 only. The use of code not covered in Chapters 1-7 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 5-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 0.00 degrees and no higher than 45.56 degrees. For Snowy days, a valid Celsius temperature is no lower than -20.56 degrees and no higher than 0.00 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 object-oriented program that avoids stale data using basic object-oriented 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 object-oriented 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 no-arg), 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 *(9/5))+32
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 +273.15
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: 14
ERROR: INVALID NUMBER OF DAYS ENTERED. TRY AGAIN.
Enter the number of days in the Weather Report: 0
ERROR: INVALID NUMBER OF DAYS ENTERED. TRY AGAIN.
Enter the number of days in the Weather Report: 2
Enter the weather conditions for Day 1:
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 1:
A - Sunny
B - Cloudy
C - Rainy
D - Snowy
Enter your choice (A, B, C, or D): B
Enter the high Celsius temperature for Day 1: 100
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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Spatial And Temporal Databases 8th International Symposium Sstd 2003 Santorini Island Greece July 2003 Proceedings Lncs 2750

Authors: Thanasis Hadzilacos ,Yannis Manolopoulos ,John F. Roddick ,Yannis Theodoridis

2003rd Edition

3540405356, 978-3540405351

More Books

Students also viewed these Databases questions