public class Conditionals
1: import java.util.Scanner;
3: /**
4: * Makes a comment about the weather
5: *
6: * @author Mark Young (A00000000)
7: */
8: public class Conditionals {
10: /**
11: * Run this program.
12: *
13: * @param args command lines arguments (ignored)
14: */
15: public static void main(String[] args) {
16: // Introduce self
17: System.out.println("\n"
18: + "Temperature Comment\n"
19: + "-------------------\n\n"
20: + "This program makes (very) small talk.\n");
22: // create variables
23: Scanner kbd = new Scanner(System.in);
24: int temp;
26: // get temperature
27: System.out.print("What's the temperature (in \u00b0C)? ");
28: temp = kbd.nextInt();
29: kbd.nextLine();
30: System.out.println();
32: // comment on temperature
33: if (30 <= temp) {
34: System.out.println("It's hot!");
35: } else if (25 <= temp) {
36: System.out.println("It's warm!");
37: } else if (15 <= temp) {
38: System.out.println("It's nice!");
39: } else if (5 <= temp) {
40: System.out.println("It's cool!");
41: } else {
42: System.out.println("It's cold!");
43: }
44: System.out.println();
45: }
47: }