Q1: Which of the following boolean expressions is appropriate to test if the age of a person is at least 18 and their weight is no more than 20 kilograms?
Problem: Any score that is less than 50 is considered outstanding. Any score that is 100 or more is considered invalid. Any score that is at least 50 less than 100 is acceptable.
Problem: If the length of the envelope at least 10 inches, then the price is determined by its weight. If the weight is less than 6 ounces then the price is $2.00; otherwise the price is $3.00. If the length of the envelope is less than 10 inches then the price is $1.00.
N north
S south
E east
W west
all other values unknown
switch (windDirection) { // line 1
case N: System.out.println("north"); // line 2
case S: System.out.println("south"); // line 3
case E: System.out.println("east"); // line 4
case W: System.out.println("west"); // line 5
default: System.out.println("unknown"); // line 6
} // line 7
Q5: Put the code in the right order to create a program that will determine the appropriate ticket price based on the time of day and age of the customer (both integers). If it is before 4pm (1600), then all tickets are $10.50. Otherwise if it is before 7pm (1900) and the customer is younger than 17 then the price is $12.00. If it is before 7pm and the customer is at least 17 then the price is $15.75. If it is 7pm (1900) or later, and the customer is younger than 17 then the price is $15.00. Otherwise the ticket price is $21.00.