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
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...
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...
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...
Write a 4-6 sentence summary explaining how you can use STL templates to create real world...
Write a 4-6 sentence summary explaining how you can use STL templates to create real world applications. In your summary, provide an example of a software project that you can create using STL templates and provide a brief explanation of the STL templates you will use to create this project. After that you will implement the software project you described . Your application must be a unique project and must incorporate the use of an STL container and/or iterator and...
In this assignment you will write a program that compares the relative strengths of two earthquakes,...
In this assignment you will write a program that compares the relative strengths of two earthquakes, given their magnitudes using the moment magnitude scale. Earthquakes The amount of energy released during an earthquake -- corresponding to the amount of shaking -- is measured using the "moment magnitude scale". We can compare the relative strength of two earthquakes given the magnitudes m1 and m2 using this formula: f=10^1.5(m1−m2) If m1>m2, the resulting value f tells us how many times stronger m1...
n this lab, you use what you have learned about parallel arrays to complete a partially...
n this lab, you use what you have learned about parallel arrays to complete a partially completed C++ program. The program should: Either print the name and price for a coffee add-in from the Jumpin’ Jive Coffee Shop Or it should print the message Sorry, we do not carry that. Read the problem description carefully before you begin. The file provided for this lab includes the necessary variable declarations and input statements. You need to write the part of the...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT