Question
JAVA: 3 classes used to store and display the barometric pressure that was input. This program needs 3 classes, Driver, WeatherStation, and KeyboardUltis. WeatherStation needs
JAVA: 3 classes used to store and display the barometric pressure that was input.
This program needs 3 classes, Driver, WeatherStation, and KeyboardUltis.
WeatherStation needs these variables:
private static int DEFAULT_MAX_COUNT = 5; private int MAX_COUNT; private double[] pressures; private int count;
And these methods:
public WeatherStation(), public WeatherStation(int MAX_COUNT), public void addBarometricPressure(double pressure), public int getMaxCount(), public int getCurrentCount(), public String toString()
The WeatherStation class does not prompt the user, and the KeyboardUltis class ensures that the program won't crash when a user types a string when a numeric is expected.
The Driver program shall prompt the user for how many barometric pressures they would enter (integer datatype) and then instantiate the WeatherStation calling the 1-ARG constructor.
For a barometric pressure value, the LOWEST value that is acceptable is [ 25.69 ] and the HIGHEST value is [ 32.005 ]. When the add pressure method is called, that method validates the value passed in, and if it is invalid, it throws an exception.
If the user enters a wrong barometric pressure value, the program shall display an appropriate error message (see the screenshot), and continue to LOOP until the user enters a valid barometric pressure value (which means you will need yer another LOOP within the driver program that uses an appropriate TRY/CATCH block).
It should look like this:
Run: Driver "C:\Program Files Javaljdk1.8.0 152 bin java.exe" - Enter the max # of barometric pressures you will type: 2 Enter a barometric pressure value [up to 2 (1) Add (2) Quit ?1 Enter the barometric pressure value: 29.92 Enter a barometric pressure value [up to 2 1) Add (2) Quit?1 Enter the barometric pressure value: dgsdfgsdfg Invalid input. Please try again... Enter the barometric pressure value: bbb Invalid input. Please try again... Enter the barometric pressure value: 30.32 Weatherstation (MAX_COUNT-2, count-2, pressures-[29.92, 30.32]) Process finished with exit code 0 Run: Driver "c: \Program FilesJavaljdk1.8.0152binljava.exe"... Enter the max # of barometric pressures you will type: 2 Enter a barometric pressure value [up to 2] (1) Add (2) Quit? 1 Enter the barometric pressure value: 9.99 Invalid Barometric Pressure Enter the barometric pressure value: 5.55 Invalid Barometric Pressure Enter the barometric pressure value: 99.99 Invalid Barometric Pressure Enter the barometric pressure value: 29.92 Enter a barometric pressure value [up to 2] (1) Add (2) Quit? 1 Enter the barometric pressure value: 31.21 WeatherStation (MAX_COUNT-2, count-2, pressures-[29.92, 31.21]) Process finished with exit code 0Step 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