New to JAVA
Posted on 2006-10-22
hi, i m new to java and would like to learn more about java.
Currently, i saw a website about temperature system.
Can anyone help me to show the working how to do the coding in java?
In this problem you will write a program that recommends sporting events based on a given temperature, from -20 to 110 degrees farenheit. The temperature is entered in the keyboard by the user of the program. The basis of the recommendation is:
swimming >= 75 degrees
tennis 60 < temperature <= 85
skiing 10 < temperature <= 32
checkers <= 10 degrees
soccer 32 < temperature <= 70
For example, if the temperature is 65 degrees, you program would recommend tennis and soccer.
Here is how you go about writing this program.
First, write a class named Exercise that includes three private, non-static variables. These variables are to be named lowtemp, hightemp and name. You will have to decide how to represent these variables and which access methods and/or constructors are needed.
Second, write a class named Activities that includes the following private, non-static variables: swimming, tennis, skiing, checkers, and soccer. Each of these variables are to be references to their own instance of an Exercise class. The instance of the Exercise class to which each refers is to have its lowtemp, hightemp and name variables set to values based on the information provided above for the temperatures for each activity. You must add at least one additional activity, though you can add more. This additional activity can be your favorite activity.
Third, write a program that uses a single instance of the Activites class to make recommendations for activities. Us eyour existing methods to read in a value within the reasonable range of temperatures and gracefully handle any cases where the value entered is not a reasonable temperature. By gracefully handle, your program should inform the user of the problem and allow the user to enter another value. Once a reasonable temperature is entered, have your program display which activities, based on the settings of the lowtemp and hightemp variables associated with each activity, are reasonable for that temperature.