public class Exercise {
private int lowtemp;
private int hightemp;
private String name;
public void setlowtemp( int lowt)
{
lowtemp = lowt;
}
public int getlowtemp()
{
return lowtemp;
}
public void sethightemp( int hight)
{
hightemp = hight;
}
public int gethightemp()
{
return hightemp;
}
public void setname( String n)
{
name = n;
}
public String getname()
{
return name;
}
public void displayMessage()
{
System.out.println("Please enter the temperature"+ gethightemp());
System.out.println("Please enter the temperature"+ getlowtemp());
System.out.println("Please enter the temperature"+ getname());
}
public class Activities extends Exercise{
public static void main(String[] args) throws IOException {
BufferedReader input=new BufferedReader (new InputStreamReader(System.in));
Activities acts = new Activities();
acts.printAllowedActivities(temp);
2006-11-19
12:28:41
·
1 answers
·
asked by
Anonymous
in
Computers & Internet
➔ Programming & Design
mp);
swimming = new Exercise("swimming")
private String swimming;
swimming.setName("swimming");
swimming.setLowTemp(75);
swimming.setHighTemp(120);
tennis = new Exercise("tennis")
private String tennis;
tennis.setName("tennis");
tennis.setLowTemp(60);
tennis.setHighTemp(85);
}
public void printAllowedActivities(int temp) {
if (temp > swimming.getLowTemp() && temp < swimming.getHighTemp()) {
System.out.println("Swimming is good for this temp");
}
if(temp>tennis.getLowTemp() && temp < tennis.getHighTemp()) {
System.out.println("Tennis is good for this temp");
}
}
public void inputTemperature(){
Scanner input = new Scanner ( System.in );
System.out.print("\nEnter the temperature: ");
int temperature;
char activities;
if (temperature >= 75) {
activities = 'swimming';
}
else if(temperature > 60 && temperature <= 85){
activities = 'tennis';
}
2006-11-19
12:32:36 ·
update #1
}
else(temperature >=-21 && temperature <=111 ){
activities = 'no activities';
System.out.println("Activities = " + activities);
}
}
}
2006-11-19
12:32:58 ·
update #2