Question

Write a program that ask the user for the year he/she was born, then outputs "Hi"...

Write a program that ask the user for the year he/she was born, then outputs "Hi" if the user is less than 18 years old but "Hello" if the user is 18 or older. The program should print "Bye" at the end.

cpp.

0 0
Add a comment Improve this question Transcribed image text
Answer #1
#include <iostream>

using namespace std;

int main()
{
    int year, age;
    
    cout<<"What year you born? ";
    cin>>year;
    
    age = 2019 - year;
    
    if(age < 18){
        cout<<"Hi"<<endl;
    }
    else{
        cout<<"Hello"<<endl;
    }
    cout<<"Bye"<<endl;

    return 0;
}

Add a comment
Know the answer?
Add Answer to:
Write a program that ask the user for the year he/she was born, then outputs "Hi"...
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
  • Python help. Write a program that asks the user to enter a person's age. The program...

    Python help. Write a program that asks the user to enter a person's age. The program should display a message indicating whether the person is an infant, a child, a teenager, or an adult. Following are the guidelines: If the person is 2 year old or less, he or she is an infant. If the person is older than 2 year, but younger than 13 years, he or she is a child. If the person is at least 13 years...

  • write a program to ask the user if he or she wants to know about their...

    write a program to ask the user if he or she wants to know about their birth stone. if they do, then display the 12 months and allow user to select the month of thier choice. give them info using their birth stone

  • Please write a Java program that ask the user how many beers he or she expects...

    Please write a Java program that ask the user how many beers he or she expects to consume each day, on average, as well as the average amount of money he or she spends on a single 12-ounce can of beer. Studies have shown that, on average, someone who consumes a single 12-ounce can of beer every day without compensating for the calorie intake through diet modifications or extra exercise, will gain approximately 15 pounds in one year. You can...

  • . Write a program that reads in a length in feet and inches and outputs the...

    . Write a program that reads in a length in feet and inches and outputs the equivalent length in meters and centimeters. 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. There are 0.3048 meters in a foot, 100 centimeters in a meter, and 12 inches...

  • Write a c++ program that asks the user for his birth year. If the birth year...

    Write a c++ program that asks the user for his birth year. If the birth year is later than 2000, then the program outputs the string “You were born in the 21st century”. If the birth year is not greater than 2000, then the program enters the else clause of the outer if statement. This clause starts by outputting the string “You were born in” before comparing the birth year to 1950. If the birth year is less than 1950,...

  • Java language. Write a short program that allows the user to enter the year that they...

    Java language. Write a short program that allows the user to enter the year that they were born (as an integer) and outputs the age that they will be at the end of this year. Declare the current year as a constant.

  • Q1: Write a Java program that will display different messages depending on your age. Your program...

    Q1: Write a Java program that will display different messages depending on your age. Your program should ask the user for his/her name and their age in years and give one or more answers from the following ones below: if the age of the user is less than 16, the program should print on the screen “You are not allowed to drive at the moment”. if the age of the user is less than 18, the program should print on...

  • JAVA HELP Create a small program where You ask the user The amount of money he/she...

    JAVA HELP Create a small program where You ask the user The amount of money he/she wants to convert using GUI Pop up input (import javax.swing.JOptionPane;) The first pop up should ask the user to what currency he/she wants to convert, He needs to be able to click that option, The currency you should use are : Euros , Pesos , Yen , Pound , Ruble, Quetzal, Once the user Clicks the option It will ask The amount the user...

  • In Java Write a program that will ask the user for integers and print if the...

    In Java Write a program that will ask the user for integers and print if the integer is positive, negative or zero. The program should continue asking for integer until the user enters a negative value.

  • Write a multithreaded a Java program that outputs prime numbers. This program should work as follows:...

    Write a multithreaded a Java program that outputs prime numbers. This program should work as follows: The user will run the program and will enter a number on the command line, The program will then create a separate thread that outputs all the prime numbers less than or equal to the number entered by the user.

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