Question

Your robot will draw a birthday cake for a child. Dusplay the wirds "Happy birthday." Display...

Your robot will draw a birthday cake for a child. Dusplay the wirds "Happy birthday." Display the child's age by entering both the child's year if birth and the current yr and then ti display the output. Example 2018-2020 is 2. The output to the last program is an integer. Produce the program that edits, compiles, and executes the tasks.

C++programming

How can I write a program in C++ witth the folowng statement. Display the words “Happy Birthday.”
Display your child’s age by entering both your child’s year of birth and the current year as inputs. You will need your program to deduct your child’s year of birth from the current year and then to display the output. For example, 2016 minus 2010 is six. Note: The output to the last program is an integer.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

/* C++ program that prompts user to enter year of birth current year and then find the age and then display message and age to console output. */
//main.cpp

//include header files
#include<iostream>
#include<string>
using namespace std;
int main()
{
   //declare variables
   int birthYear;
   int currentYear;
   int age=0;

   //set message of happy birth day
   string message="Happy Birthday!";

   //read birth year and current year
   cout<<"Enter year of birth : ";
   cin>>birthYear;

   cout<<"Enter current year : ";
   cin>>currentYear;

   //calcuate the number of years
   age=currentYear-birthYear;

   cout<<message<<endl;
   cout<<"Your age is "<<age<<endl;


   //pause program output on console
   system("pause");
   return 0;
}

Sample Output:

Add a comment
Know the answer?
Add Answer to:
Your robot will draw a birthday cake for a child. Dusplay the wirds "Happy birthday." Display...
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
  • JAVA Using the data provided in the attachment, create a program that will display a child's...

    JAVA Using the data provided in the attachment, create a program that will display a child's predicted adult height. This program will need to create an array of objects to search. This program needs to validate the input for valid range and input values. If invalid data is given, the program needs to indicate that data is invalid and suggest appropriate values/ranges. However, you do not need to validate alphabetic data given for numeric input. 1. The program will need...

  • Write a C++ program that determines the user's age after the user enters both the current...

    Write a C++ program that determines the user's age after the user enters both the current date and hisher birthdate as 3 integers: yyyy mm dd Define a class which is named DateType and will be used to declare 2 objects: "birthday" and "today". The class will have a function "output" which will display the date in conventional form (like it is above next to Date Assigned: Month dd, yyyy EXAMPLE: If the user entered the #’s: 2018 2 6...

  • Today is your 22nd birthday, and your grandmother just gave you $5000. G-ma’s gift comes with...

    Today is your 22nd birthday, and your grandmother just gave you $5000. G-ma’s gift comes with the condition that you must invest the money and save it for your retirement. You’ve found an investment that is expected to earn an annualized rate of return of 8.4% per year forever. In 8 years, in order to save even more money for retirement, you will begin making annual deposits into the investment account. The first payment will be $6500, and subsequent payments...

  • Write a C++ program that determines the user's age after the   user enters both the current...

    Write a C++ program that determines the user's age after the   user enters both the current date and hisher birthdate as 3   integers:                yyyy mm dd                                                                                             Define a class which is named DateType and will be used to     declare 2 objects: "birthday" and "today". The class will have a function "output" which will display the date in conventional form (like it is above next to Date Assigned: Month dd, yyyy and it will have a second function named     “input”...

  • Your sister is celebrating her 32nd birthday. As the party winds down she asks for your...

    Your sister is celebrating her 32nd birthday. As the party winds down she asks for your assistance in helping her plan for retirements because she knows that you are taking a finance course in your MBA program. She wants to start saving now for retirement at age 62. She tells you that ideally she would like to withdraw $50,000 on an annual basis for at least 20 years starting the year after she retires at age 62. She says that...

  • Write a program called RentalRate.java which reads in a date of birth, today’s date and a...

    Write a program called RentalRate.java which reads in a date of birth, today’s date and a male/female designation from the user, and will then determine the basic daily and weekly rates for rental of an economy class car. Rental rate classes are: Best rate (male drivers, age 33–65 and female drivers, age 30-62)--$40.00per day, $200.00 per week Risk rate 1 (female drivers, age 25–29)–Best rate plus $10.00 per day or best rate plus $55.00 per week. Risk rate 2 (male...

  • C++ : Please include complete source code in answer This program will have names and addresses...

    C++ : Please include complete source code in answer This program will have names and addresses saved in a linked list. In addition, a birthday and anniversary date will be saved with each record. When the program is run, it will search for a birthday or an anniversary using the current date to compare with the saved date. It will then generate the appropriate card message. Because this will be an interactive system, your program should begin by displaying a...

  • using this code to complete. it python 3.#Display Program Purpose print("The program will show how much...

    using this code to complete. it python 3.#Display Program Purpose print("The program will show how much money you will make working a job that gives a inputted percentage increase each year") #Declaration and Initialization of Variables userName = "" #Variable to hold user's name currentYear = 0 #Variable to hold current year input birthYear = 0 #Variable to hold birth year input startingSalary = 0 #Variable to hold starting salary input retirementAge = 0 #Variable to hold retirement age input...

  • Part A Your sister is celebrating her 30th birthday. As the party winds down she asks you for some help. She wants to s...

    Part A Your sister is celebrating her 30th birthday. As the party winds down she asks you for some help. She wants to start saving for her retirement at age 60. She tells you that ideally she would like to withdraw $50,000 on an annual basis for 20 years starting the year after she retires. She says that she would be comfortable putting aside some money each year in an annuity and believes that she would be able to earn...

  • NOTE: LANGUAGE IS PYTHON CS160 Computer Science Lab 17 Objectives Work with dictionaries Work with functions...

    NOTE: LANGUAGE IS PYTHON CS160 Computer Science Lab 17 Objectives Work with dictionaries Work with functions Work with files Overview This lab will have you store the birthdays for a group of people. This program will store the information with the focus on the date of the month and not on the individual. The point of this program is to be able to see who has a birthday on a given day or to create a table of birthdays, in...

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