Summary In this lab, you declare and initialize variables in a C++ program. The program, which is saved in a file named NewAge.cpp, calculates your age in the year 2050. Instructions Declare an integer variable named myNewAge. Declare and initialize an integer variable named myCurrentAge. Initialize this variable with your current age. Declare and initialize an integer variable named currentYear. Initialize this variable with the value of the current year. Use four digits for the year. Execute the program by clicking the Run button at the bottom of the screen. Sample program execution: My Current Age is 29. I will be 65 in 2050.

I am not sure how to add my output.

This is what I have so far:

// This program calculates your age in the year 2050.

// Input: None // Output: Your current age followed by your age in 2050

#include using namespace std;

int main()

'currentYear'; /2019/.match('currentYear') =>MatchData "2019"

'myCurrentAge'; /20/.match('myCurrentAge') => > "My Current Age is" count >> 'myCurrentAge'

int 'currentYear'

'currentYear'= 2019;

count >> "Current Year"

count >> 'currentYear'

int 'myNewAge'

'myNewAge'= 51;

count >> "I will be"

count >> 'myNewAge'

51 = 20 + (2050 - 2019);

cout << "My Current Age is " << 20 << endl;

cout << "I will be " << 51 << " in 2050." << endl;

return 0; }

Respuesta :

ijeggs

Answer:

#include <iostream>

using namespace std;

int main()

{

 int myNewAge;

 int myCurrentAge = 29;

 int currentYear = 2020;

myNewAge = myCurrentAge+(2050-currentYear);

cout<<"My Current Age is "<<myCurrentAge<<". I will be "<<myNewAge<<" in 2050"<<endl;

   return 0;

}

Explanation:

The program is written in C++ language as required. firstly, we declare the three variables:

 int myNewAge;

 int myCurrentAge = 29;

 int currentYear = 2020;

Then we calculate the new age as: myNewAge = myCurrentAge+(2050-currentYear);

Using multiple cout operators ( <<) we display the output nicely as required by the question with this statement

cout<<"My Current Age is "<<myCurrentAge<<". I will be "<<myNewAge<<" in 2050"<<endl;

To make corrections to your code, implies that we debug the code. The following are the reasons why your code is not working.

The errors in the code is quite much, so I will rewrite the program, where comments are used to explain difficult line of the program

#include<iostream>

using namespace std;

int main(){

//This declares all variables

int myCurrentAge, myNewAge, currentYear;

//This initializes currentYear to the current year

currentYear = 2021;

//This initializes myCurrentAge to your current age

myCurrentAge = 20;

//This calculates your new age

myNewAge = 2050 - 2021 + myCurrentAge;

//This prints the calculated new age

cout<<"My new age: "<<myNewAge;

return 0;

}

Read more about debugging at:

https://brainly.com/question/23527739