Making Multiple Comparisons in Decision Statements
In this exercise, you use what you have learned about OR logic to study a complete C++ program that uses OR logic in a decision statement. This program was written for a marketing research firm that wants to determine if a customer prefers Coke or Pepsi over some other drink. Take a few minutes to study the code that follows, and then answer Questions.
// CokeOrPepsi.cpp - This program determines if a customer// prefers to drink Coke or Pepsi or some other drink.#include#include using namespace std;int main(){string customerFirstName; // Customer's first namestring customerLastName; // Customer's last namestring drink = ""; // Customer's favorite drinkcout ≪ "Enter customer's first name: ";cin ≫ customerFirstName;cout ≪ "Enter customer's last name: ";cin ≫ customerLastName;cout ≪ "Enter customer's drink preference: ";cin ≫ drink;if(drink == "Coke" || drink == "Pepsi"){cout ≪ "Customer First Name: " ≪ customerFirstName≪ endl;cout ≪ "Customer Last Name: " ≪ customerLastName≪ endl;cout ≪ "Drink: " ≪ drink ≪ endl;}elsecout ≪ customerFirstName ≪ " " ≪ customerLastName≪ " does not prefer Coke or Pepsi." ≪ endl;return 0;}
What is the exact output from this program when
if(drink == "Coke" || drink == "Pepsi")
is changed to
if(drink == "Coke" || drink == "Pepsi" || drink == "coke" || drink == "pepsi")
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.