Question

// Lab Homework 9 // Logical Operator AND and OR // Demonstrate how to use a...

// Lab Homework 9
// Logical Operator AND and OR
// Demonstrate how to use a logical operator
// with a Boolean expression.

#include <iostream>
#include <cctype> // for tolower()
using namespace std;

int main()
{
   /* Create a program that produces the Sample Output shown at the bottom.

   You MUST:
   - Output all of the lines show below in the Sample Output - spacing, spelling, punctuation, etc. must be exact matches
   NOTE: There are FOUR different runs of the program shown - do not have your program do all four at once
   - Declare variables and/or constants appropriately, name them according to standards
   (points will be deducted for poor names), and be sure to use appropriate data types
   - You MUST use a compound conditional (you decide whether you need && or ||), only ONE if and ONE else are allowed

   */
   // <write your solution code below this comment>

  

   cout << endl << endl;

   return 0;
}

/* Sample interaction and output:

Run the program once - the user enters y and y
==========================================
Answer the following questions
with either yes or no (y or n):

Are you a student? y
Are you 65 or older? y

Congratulations!
You qualify for discounted movie tickets.

Press any key to continue . . .

Run the program a second time - the user enters y and N
==========================================
Answer the following questions
with either yes or no (y or n):

Are you a student? y
Are you 65 or older? N

Congratulations!
You qualify for discounted movie tickets.

Press any key to continue . . .

Run the program a third time - the user enters N and y
==========================================
Answer the following questions
with either yes or no (y or n):

Are you a student? N
Are you 65 or older? y

Congratulations!
You qualify for discounted movie tickets.

Press any key to continue . . .

Run the program a fourth time - the user enters n and N
==========================================
Answer the following questions
with either yes or no (y or n):

Are you a student? n
Are you 65 or older? N

Sorry.
You must be a student or a senior citizen to receive discounted movie tickets.

Press any key to continue . . .

*/

Homework Answers

Answer #1
// Lab Homework 9
// Logical Operator AND and OR
// Demonstrate how to use a logical operator
// with a Boolean expression.

#include <iostream>
#include <cctype> // for tolower()

using namespace std;

int main() {
    /* Create a program that produces the Sample Output shown at the bottom.

    You MUST:
    - Output all of the lines show below in the Sample Output - spacing, spelling, punctuation, etc. must be exact matches
    NOTE: There are FOUR different runs of the program shown - do not have your program do all four at once
    - Declare variables and/or constants appropriately, name them according to standards
    (points will be deducted for poor names), and be sure to use appropriate data types
    - You MUST use a compound conditional (you decide whether you need && or ||), only ONE if and ONE else are allowed

    */
    // <write your solution code below this comment>
    char student, senior_citizen;
    cout << "Answer the following questions" << endl;
    cout << "with either yes or no (y or n):" << endl;
    cout << "Are you a student? ";
    cin >> student;
    cout << "Are you 65 or older? ";
    cin >> senior_citizen;
    student = tolower(student);
    senior_citizen = tolower(senior_citizen);

    if (student == 'y' || senior_citizen == 'y') {
        cout << "Congratulations!" << endl;
        cout << "You qualify for discounted movie tickets." << endl;
    } else {
        cout << "Sorry." << endl;
        cout << "You must be a student or a senior citizen to receive discounted movie tickets." << endl;
    }

    cout << endl << endl;

    return 0;
}
Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
/* Homework Lab 4 - Using manipulators to format output */ //***************************************************************** // Mortgage Payment Calculator...
/* Homework Lab 4 - Using manipulators to format output */ //***************************************************************** // Mortgage Payment Calculator program // This program determines the monthly payments on a mortgage given // the loan amount, the yearly interest, and the number of years. //***************************************************************** #include <iostream> // Access cout #include <cmath> // Access power function #include <iomanip> // Access manipulators using namespace std; const float LOAN_AMOUNT = 50000.00; // Amount of the loan const float YEARLY_INTEREST = 0.0524; // Yearly interest rate const...
Selection control structure The if statement The switch statement (optional) Relational operators and logical operators Use...
Selection control structure The if statement The switch statement (optional) Relational operators and logical operators Use of relational and logical operators to check numeric ranges User friendly Use of user friendly user prompt and simple input validation Use of meaningful output labels and format Use of output manipulators Working with string type Use of getline() Project Description There are two main systems for measuring distance, weight and temperature, the Imperial System of Measurement and the Metric System of Measurement. Most...
Python code only! (Do not include breaks or continue functions) Write a program that asks the...
Python code only! (Do not include breaks or continue functions) Write a program that asks the user to enter the amount that they budgeted for the month. A loop should then prompt the user to enter their expenses, one at a time and to enter 0 to quit. When the loop finishes, the program should display the the amount of budget left. (a negative number indicates the user is over budget and a positive number indicates the user is under...
This is a very short trivia game. See if the user can guess the year that...
This is a very short trivia game. See if the user can guess the year that MDC (formerly Dade County Junior College) first started offering classes (1960). If the user guesses incorrectly, ask if they want another attempt. Once the user gets it right, report the number of guesses needed and end the program. Initial Output: MDC was originally named Dade County Junior College. Output (per loop) In what year were classes first offered? [user types: 1980] That answer is...
Hi, I need a program in C, where it will prompt a user for a math...
Hi, I need a program in C, where it will prompt a user for a math quiz, either easy or medium. If the user choses difficulty easy, it will prompt the user for how many questions they would like from 1-5. If the user enters medium it will prompt the user on how many questions they would like from 1-10. After those prompts are entered questions will be displayed using rand(), the questions must be multiple choice or division, aswell...
PLEASE CODE IN C# NOT in Java EXCEPTION HANDLING Concept Summary: Use of try... catch in...
PLEASE CODE IN C# NOT in Java EXCEPTION HANDLING Concept Summary: Use of try... catch in a program Define an exception class and call it from the driver program. For this lab you will complete two parts. Part (a) of the lab implements try... catch and uses an existing exception in C#. Write a program that implements an ArrayIndexOutOfBounds error. Part (b) writes a program that converts a time from 24-hour notation to 12-hour notation. Assume the user will enter...
USE C++!!!! Encryption and Decryption are two cryptographic techniques. Encryption is used to transform text to...
USE C++!!!! Encryption and Decryption are two cryptographic techniques. Encryption is used to transform text to meaningless characters, and decryption is used to transform meaningless characters into meaningful text. The algorithm that does the encryption is called a cipher. A simple encryption algorithm is Caesar cipher, which works as follows: replace each clear text letter by a letter chosen to be n places later in the alphabet. The number of places, n, is called the cipher key. For example, if...
."Ask the user to input a number.  You must use an input dialog box for this input....
."Ask the user to input a number.  You must use an input dialog box for this input. Be sure to convert the String from the dialog box into an integer (int). The program needs to keep track of the smallest number the user entered as well as the largest number entered. Use a Confirm dialog box to ask the user if they want to enter another number. If yes, repeat the process. If no, output the smallest and largest number that...
How much money do you think you would earn in a period of 30 days if...
How much money do you think you would earn in a period of 30 days if you were paid as follows: one cent for the first day, two cents for the second day, four cents for the third day, eight cents for the fourth day, and so on (i.e. your salary doubles each day)? Do you think you would make very little money, just a few dollars, at the end of the 30-day period? Let us write a program to...
Coffee Order Structure Assignment Write a program that uses a structure for a coffee order. A...
Coffee Order Structure Assignment Write a program that uses a structure for a coffee order. A coffee order consists of a double price, a string for flavor, and characters for cream (Y/N), sugar (Y/N), and coffee size (S/M/L). Your main() function will call an order function that will ask the user for the flavor, size and whether or not they want cream or sugar. Your main() function will then create a coffee order structure and assign all of the values...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT