Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- class Main {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- int temp;
- String activity = "";
- // input temperature
- System.out.println("Please enter the temperature:");
- temp = scan.nextInt();
- // suggest activity
- /*
- * temp >= 80: swimming
- 60 <= temp < 80: tennis
- 40 <= temp < 60: golf
- temp < 40: skiing
- */
- if (temp >= 90 || temp <= 20) {
- activity = "visit our shops";
- } else {
- if (temp >= 80) {
- activity = "Go swimming.";
- } else if (temp >= 60) {
- activity = "Play tennis.";
- } else if (temp >= 40) {
- activity = "Play golf.";
- } else {
- activity = "Go skiing.";
- }
- }
- //output results
- System.out.println(activity);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement