Question

Underage drinking. make a short as possible for both wild and do wild in c++ Please...

Underage drinking.


make a short as possible for both wild and do wild in c++


Please write a program that asks the user to input his/her age.

If age is under 21, he/she is not allowed to drink. Printout a statement saying, "You can't drink you're under 21".

If he/she is 21 or older, printout a statement saying, "Welcome to our bar". However, the bar has a capacity of only 3 people.

After letting 3 people above 21 into the bar, printout a statement saying, "The bar is full, sorry we have reached our capacity".

Program ends.

Do the above program using a while and do-while.

1- Declare your variables, age, and max (max is =1 and is a counter). Both are of an int data type.

2-cout << "Welcome to our bar:\n";

3--cout << " A statement saying under 21 can't drink and we have a limited capacity ";

ask for age;

4-Then use a while loop While (age ? 21 ? max ? 3)

{

your codes go here. Also, cout and cin again.

}

cout << "sorry we have reached our capacity ";


return 0;


note:? means you need to figure that out.

make a short as possible for both wild and do wild

0 0
Add a comment Improve this question Transcribed image text
Answer #1

# If you have a query/issue with respect to the answer, please drop a comment. I will surely try to address your query ASAP and resolve the issue

# # Please consider providing a thumbs up to this question if it helps you. by doing that, you will help other students who are facing a similar issue.

//----------------------OUTPUT------------------------------------

Welcome to our bar under 21 cant drink and we have a limited capacity. enter your Age: 20 You cant drink youre under 21 en

//----------------------USING WHILE -----------------------------------------

#include <iostream>

using namespace std;

int main() {

    int count=0;

    cout<<"Welcome to our bar\n";

    int age;

    cout << "under 21 can't drink and we have a limited capacity. \n";

    while(count<3){

        cout<<"enter your Age: ";

        cin>>age;

        if(age>=21){

            count++;

            cout<<"Welcome to our bar\n";

        }

        else{

            cout<<"You can't drink you're under 21\n";

        }

    }

    cout << "The bar is full, sorry we have reached our capacity";

}

//--------------------------------USING DO-WHILE---------------------------------

#include <iostream>

using namespace std;

int main() {

    int count=0;

    cout<<"Welcome to our bar\n";

    int age;

    cout << "under 21 can't drink and we have a limited capacity. \n";

    do{

        cout<<"enter your Age: ";

        cin>>age;

        if(age>=21){

            count++;

            cout<<"Welcome to our bar\n";

        }

        else{

            cout<<"You can't drink you're under 21\n";

        }

    }

    while(count<3);

    cout << "The bar is full, sorry we have reached our capacity";

}

Add a comment
Know the answer?
Add Answer to:
Underage drinking. make a short as possible for both wild and do wild in c++ Please...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • C LANGUAGE. PLEASE INCLUDE COMMENTS :) >>>>TheCafe V2.c<<<< #include ...

    C LANGUAGE. PLEASE INCLUDE COMMENTS :) >>>>TheCafe V2.c<<<< #include <stdio.h> int main() { int fries; // A flag denoting whether they want fries or not. char bacon; // A character for storing their bacon preference. double cost = 0.0; // The total cost of their meal, initialized to start at 0.0 int choice; // A variable new to version 2, choice is an int that will store the // user's menu choice. It will also serve as our loop control...

  • please use python and provide run result, thank you! click on pic to make it bigger...

    please use python and provide run result, thank you! click on pic to make it bigger For this assignment you will have to investigate the use of the Python random library's random generator function, random.randrange(stop), randrange produces a random integer in the range of 0 to stop-1. You will need to import random at the top of your program. You can find this in the text or using the online resources given in the lectures A Slot Machine Simulation Understand...

  • Lab 5.1 C++ Utilizing the code from Lab 4.2, replace your Cargo class with a new...

    Lab 5.1 C++ Utilizing the code from Lab 4.2, replace your Cargo class with a new base class. This will be the base for two classes created through inheritance. The Cargo class will need to have virtual functions in order to have them redefined in the child classes. You will be able to use many parts of the new Cargo class in the child classes since they will have the same arguments/parameters and the same functionality. Child class one will...

  • Pat Miranda, the new controller of Vault Hard Drives, Inc., has just returned from a seminar...

    Pat Miranda, the new controller of Vault Hard Drives, Inc., has just returned from a seminar on the choice of the activity level in the predetermined overhead rate. Even though the subject did not sound exciting at first, she found that there were some important ideas presented that should get a hearing at her company. After returning from the seminar, she arranged a meeting with the production manager, J. Stevens, and the assistant production manager, Marvin Washington. Pat: I ran...

  • Pat Miranda, the new controller of Vault Hard Drives, Inc., has just returned from a seminar...

    Pat Miranda, the new controller of Vault Hard Drives, Inc., has just returned from a seminar on the choice of the activity level in the predetermined overhead rate. Even though the subject did not sound exciting at first, she found that there were some important ideas presented that should get a hearing at her company. After returning from the seminar, she arranged a meeting with the production manager, J. Stevens, and the assistant production manager, Marvin Washington. Pat: I ran...

  • Pat Miranda, the new controller of Vault Hard Drives, Inc., has just returned from a seminar...

    Pat Miranda, the new controller of Vault Hard Drives, Inc., has just returned from a seminar on the choice of the activity level in the predetermined overhead rate. Even though the subject did not sound exciting at first, she found that there were some important ideas presented that should get a hearing at her company. After returning from the seminar, she arranged a meeting with the production manager, J. Stevens, and the assistant production manager, Marvin Washington. Pat: I ran...

  • Pat Miranda, the new controller of Vault Hard Drives, Inc., has just returned from a seminar...

    Pat Miranda, the new controller of Vault Hard Drives, Inc., has just returned from a seminar on the choice of the activity level in the predetermined overhead rate. Even though the subject did not sound exciting at first, she found that there were some important ideas presented that should get a hearing at her company. After returning from the seminar, she arranged a meeting with the production manager, J. Stevens, and the assistant production manager, Marvin Washington Pat: I ran...

  • just answer, do not need explain.asap thank you QUESTION 3 Semantics is: the way we make...

    just answer, do not need explain.asap thank you QUESTION 3 Semantics is: the way we make meaning of words o the smallest speech units that carry meaning the smallest distinctive unit of sound in language rules for combining words into grammatically correct sentences QUESTION 4 The Cannon-Bard Theory of emotion states that (hint: this is the second one that we talked about): an emotion-arousing event simultaneously triggers both physiological arousal and the subjective experience of emotion to experience emotion one...

  • Hi can you help me make a summary about this short article and how it affects...

    Hi can you help me make a summary about this short article and how it affects me economically as US ciizen ? US-China Trade Talks Wrap Up After Extending To Third Day Facebook Twitter Flipboard Email January 9, 20196:39 AM ET Matthew S. Schwartz Twitter U.S. and Chinese envoys extended trade talks into a third day Wednesday after President Donald Trump said negotiations aimed at ending a tariff war were "going very well!" Oliver Zhang/AP After extending to an unexpected...

  • Please read the attached article from the New York Times and write a short paper answering...

    Please read the attached article from the New York Times and write a short paper answering the below questions. There is no length minimum for the essay. I would anticipate approximately 1-2 pages double-spaced, 12pt Times New Roman font to address all required elements. Papers over 2 pages will receive an automatic reduction of 50%. Your task is to accomplish two goals in your paper: Analyze a business problem(s) presented in the article and describe its effect on the business...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT