import java.io.*;
public class Activities extends Exercise{
public static Activities swimming= new Activities();
public static Activities tennis= new Activities();
public static Activities bowling= new Activities();
public static void main(String[] args) {
BufferedReader input=new BufferedReader (new
InputStreamReader(System.in));
swimming.setName("swimming");
swimming.setLowTemp(75);
swimming.setHighTemp(120);
tennis.setName("tennis");
tennis.setLowTemp(60);
tennis.setHighTemp(85);
tennis.setName("bowling");
tennis.setLowTemp(20);
tennis.setHighTemp(50);
Activities acts = new Activities();
_/*
In This line you need to put the temperature to evaluate then the
2006-11-21
12:00:55
·
5 answers
·
asked by
Anonymous
in
Computers & Internet
➔ Programming & Design
*/
acts.printAllowedActivities(100);
}
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");
}
if(temp>bowling.getLowTemp() && temp < bowling.getHighTemp()) {
System.out.println("Bowling is good for this temp");
}
}
public void inputTemperature(){
int temperature;
String activities=new String();
Scanner input = new Scanner ( System.in );
System.out.print("\nEnter the temperature: ");
if (temperature >= 75) {
activities = "swimming";
}
else if(temperature > 60 && temperature <= 85){
activities = "tennis";
}
else if (temperature >=-21 && temperature <=111 ){
activities = "no activities";
2006-11-21
12:02:27 ·
update #1
System.out.println("Activities = " + activities);
}
}*/
}
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"+ getLowTemp());
System.out.println("Please enter the temperature"+ getHighTemp());
System.out.println("Please enter the temperature"+ getName());
}
}
2006-11-21
12:02:53 ·
update #2
i'm using jdk1.3
2006-11-21
12:13:13 ·
update #3
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\Documents and Settings\User>cd\
C:\>path=c:\jdk1.3\bin
C:\>cd my debug
The system cannot find the path specified.
C:\>cd debug
C:\debug>cd\
C:\>path=c:\jdk1.3\bin
C:\>cd debug
C:\debug>javac exercise.java
exercise.java:32: ';' expected
acts.printAllowedActivities(100);
^
exercise.java:51: expected
_/*public void inputTemperature(){
^
exercise.java:3: class Activities is public, should be declared in a file named
Activities.java
public class Activities extends Exercise{
^
exercise.java:51: cannot resolve symbol
symbol : class _
location: class Activities
_/*public void inputTemperature(){
^
exercise.java:29: cannot resolve symbol
symbol : class _
location: class Activities
_/*
^
exercise.java:32: acts is already defined in main(java.lang.String[])
acts.printAllowedActivities(100);
^
6 errors
C:\debug>^A
2006-11-21
12:43:04 ·
update #4