Java

Weather Advice 1

8 points

In this program, you ask the user for today's high temperature. You then give the user advice based on that temperature. You should give different advice for temperatures above 90° F, between 75° and 90°, between 60° and 75°, between 45° and 60°, between 30° and 45°, between 0° and 30°, and below 0°. You use an IF - ELSE IF - ELSE structure to give the advice.

Start by downloading WeatherAdvice.java at the link below.

In the section in which the instance variables are declared:
Replace the question marks in the Labels, IntegerField and Button.

In the constructor, replace the question mark.

In buttonClicked, set up an if - else if - else structure to respond to the day's high temperature. Visit the BreezyGUI website and click on IntegerField to learn how to extract the number the user wrote to the IntegerField. Use the .setText() method to write to a TextField. In each branch of the if - else if - else statement, write an appropriate piece of advice to the TextField.

Here is how my BreezyGUI frame looks when the program is running:

The private instance variables that you'll need are given to you in WeatherAdvice.java.

 

Demo

You can download and run CompletedWeather1.jar to see how your program will run when it is complete.

 

Starting Point

You can download WeatherAdvice.java to use as a starting point in writing your program.