Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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:

image text in transcribed

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 0

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

New Trends In Databases And Information Systems Adbis 2019 Short Papers Workshops Bbigap Qauca Sembdm Simpda M2p Madeisd And Doctoral Consortium Bled Slovenia September 8 11 2019 Proceedings

Authors: Tatjana Welzer ,Johann Eder ,Vili Podgorelec ,Robert Wrembel ,Mirjana Ivanovic ,Johann Gamper ,Mikolaj Morzy ,Theodoros Tzouramanis ,Jerome Darmont

1st Edition

3030302776, 978-3030302771

More Books

Students also viewed these Databases questions