|
-
Sep 29th, 2006, 02:25 PM
#1
Thread Starter
Junior Member
Tell me if I am doing this right
Can somebody tell me if I am doing this right. If not please tell me what I am doing wrong.
1. Write a program that prompts the user for a temperature, then prints out the activity appropriate for that temperature.
2. Modify your program so that if the temperature is greater than 95 or less than 20, it prints "Visit our shop!"
temp >= 80 Swimming
60 <= temp <80 Tennis
40 <= temp < 60 Golf
temp < 40 Skiing
import java.util.*;
import java.util.Scanner;
public class Temperature
{
public static void main(String[] args)
{
final int Swimming; //read Swimming
final int Tennis; //read Tennis
final int Golf; //read Golf
final int Skiing; //read Skiing
Scanner scan = new Scanner(System.in);
int temp;
System.out.print ("Enter the temperature: ");
temp = scan.nextInt();
System.out.println ("Activity: " + Swimming + Tennis + Golf + Skiing);
if (temp >= 80);
System.out.println("Swimming");
if (temp > 95);
if (temp < 20);
System.out.println("Visit our Shop!");
if (temp <= 60);
if (temp < 80);
System.out.println("Tennis");
if (temp <= 40);
if (temp < 60);
System.out.println("Golf");
if (temp < 40);
System.out.println("Skiing");
}
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|