Making Multiple Comparisons in Decision Statements
In this exercise, you use what you have learned about OR logic. This example program was written for a marketing research firm that wants to determine if a customer prefers Coke or Coke Zero over some other drink Study the following code and then answer Questions 1-4.
1. What is the exact output when this program executes if the customer's name is Chas Matson and the drink is Coke? _____________________________________________________________________________________
_____________________________________________________________________________________
2. What is the exact output when this program executes if the customer's name is Chas Matson and the drink is Coke Zero? _____________________________________________________________________________________
_____________________________________________________________________________________
3. What is the exact output from this program when
if(drink . equal s ("Coke")|| drink . equal s ("Coke Zero"))
is changed to
if(drink.equals("coke") || drink.equals("Coke Zero"))
and the customer's name is still Chas Matson and the drink is still Coke?
_____________________________________________________________________________________
_____________________________________________________________________________________
4. What is the exact output from this program when if(dri nk.equal s ("Coke") II drink. equal s ("Coke Zero")) is changed to
if(drink.equals("Coke") II drink.equals("coke") II
drink. equal s ("Coke Zero") II drink. equal s ("coke zero"))
and the customer's name is Chas Matson, and the drink is coke? What does this change allow a user to enter?
_____________________________________________________________________________________
_____________________________________________________________________________________
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.