Question

In: Computer Science

Make a C++ program that reads the age of a person, if the person is between...

Make a C++ program that reads the age of a person, if the person is between 12 and 17 years old, a message that says "Teenager!" otherwise print "Not a teenager."

Solutions

Expert Solution

Answer-

Your code is here-

  • #include<iostream>
  • using namespace std;
  • int main()
  • {
  •    int age;
  •    cout<<" Please Enter your age: ";
  •    cin>>age; //read the age of person
  •    if(age>=12 && age<=17) //condtion between 12 and 17 years
  •    {
  •        cout<<"Teenager!"<<endl; //display Teenager!
  •    }
  •    else
  •    {
  •        cout<<"Not a Teenager"<<endl; //display not a teenager !
  •    }
  • }

screenshot of output -

Note- Please do upvote, if any problem then comment in box sure I will help.


Related Solutions

Write a program that: (a) Reads name and age of 10 different persons (b) Stores this...
Write a program that: (a) Reads name and age of 10 different persons (b) Stores this information in a dictionary (remember, dictionary contains keys and values) (c) Sorts your dictionary based on keys (d) Sorts your dictionary based on values (e) Displays the original and both sorted dictionaries (step c and d) (f) You search for a specific person and the program displays their name and age on the screen. If the person’s information is not in the dictionary, the...
C Programming Write a program in C that reads in a file, stores its contents as...
C Programming Write a program in C that reads in a file, stores its contents as a character array/pointer (char*) into an unsigned character array/pointer (unsigned char* message). Note: the input file can have one line or multiple lines and vary in length
In c++ Write a program that reads a string consisting of a positive integer or a...
In c++ Write a program that reads a string consisting of a positive integer or a positive decimal number and converts the number to the numeric format. If the string consists of a decimal number, the program must use a stack to convert the decimal number to the numeric format. Use the STL stack
IN C LANGUAGE This program reads a threshold, a size, and an array of integers. The...
IN C LANGUAGE This program reads a threshold, a size, and an array of integers. The program then calls the foo function. The function will modify the array x of size n by doubling any values in x that are less than the threshold. The function will count how many values were changed and how many were not changed via two reference parameters. The function signature is: void foo(int n, int x[], int threshold, int *pChanged, int *pUnchanged); The function...
C++ Write a program that prompts for a file name and then reads the file to...
C++ Write a program that prompts for a file name and then reads the file to check for balanced curly braces, {; parentheses, (); and square brackets, []. Use a stack to store the most recent unmatched left symbol. The program should ignore any character that is not a parenthesis, curly brace, or square bracket. Note that proper nesting is required. For instance, [a(b]c) is invalid. Display the line number the error occurred on. These are a few of the...
This is C++ Create a program that reads an HTML file and converts it to plain...
This is C++ Create a program that reads an HTML file and converts it to plain text. Console: HTML Converter Grocery List * Eggs * Milk * Butter Specifications: The HTML file named groceries.html contains these HTML tags: <h1>Grocery List</h1> <ul> <li>Eggs</li> <li>Milk</li> <li>Butter</li> </ul> When the program starts, it should read the contents of the file, remove the HTML tags, remove any spaces to the left of the tags, add asterisks (*) before the list items, and display the...
C program, please Write a program that reads a sequence of 10 integer inputs and prints...
C program, please Write a program that reads a sequence of 10 integer inputs and prints the smallest and largest of the inputs and the number of even and odd inputs. for a beginner please, you could use a while loop,if-else,
a C++ program that reads in weight in pounds and outputs the equivalent length in Kilograms...
a C++ program that reads in weight in pounds and outputs the equivalent length in Kilograms and grams. Use at least three functions: one for input, one or more for calculating, and one for output. Include a loop that lets the user repeat this computation for new input values until the user says he or she wants to end the program. 1 pound (lb) is equal to 0.45359237 kilograms (kg). There are 1000 grams in a kilogram and 16 ounces...
You are to write a C++ program which does the following: Reads in the size of...
You are to write a C++ program which does the following: Reads in the size of a list of characters. Reads in the list of characters. Prints the list of characters in the opposite order read in. Prints the list of characters in the order read in. Sorts the list. Prints the sorted list. You may assume there will be no more than 1000 characters in the list. (You should use a constant to make this limit easily changeable.) You...
a C++ program that reads in weight in pounds and outputs the equivalent length in Kilograms...
a C++ program that reads in weight in pounds and outputs the equivalent length in Kilograms and grams. Use at least three functions: one for input, one or more for calculating, and one for output. Include a loop that lets the user repeat this computation for new input values until the user says he or she wants to end the program. 1 pound (lb) is equal to 0.45359237 kilograms (kg). There are 1000 grams in a kilogram, and 16 ounces...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT