1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
yarga [219]
3 years ago
5

Summary In this lab, you declare and initialize variables in a C++ program. The program, which is saved in a file named NewAge.c

pp, 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; }
Computers and Technology
1 answer:
AVprozaik [17]3 years ago
7 0

Answer:

<em>#include <iostream></em>

<em>using namespace std;</em>

<em>int main()</em>

<em>{</em>

<em>  int myNewAge;</em>

<em>  int myCurrentAge = 29;</em>

<em>  int currentYear = 2020;</em>

<em> </em>

<em>myNewAge = myCurrentAge+(2050-currentYear);</em>

<em />

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

<em>    return 0;</em>

<em>}</em>

Explanation:

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

<em>  </em><em>int myNewAge;</em>

<em>  int myCurrentAge = 29;</em>

<em>  int currentYear = 2020;</em>

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

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

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

You might be interested in
C++ a. Write a program that uses the function isPalindrome given in example 6-6 (Palindrome). Test your program on the followinn
Whitepunk [10]

Answer:

#include <iostream>

#include <array>

using namespace std;

bool isPalindrome(string str)  

{  

int length = str.length();  

for (int i = 0; i < length / 2; i++)  

 if (toupper(str[i]) != toupper(str[length - 1 - i]))

  return false;  

return true;  

}

int main()

{

array<string, 6> tests = { "madam", "abba", "22", "67876", "444244", "trymEuemYRT" };

for (auto test : tests) {

 cout << test << " is " << (isPalindrome(test) ? "" : "NOT ") << "a palindrome.\n";

}

}

Explanation:

The toupper() addition forces characters to uppercase, thereby making the comparison case insensitive.

5 0
3 years ago
Which tcp/ip troubleshooting command should you use to determine whether a client and server are communicating with each other?
sesenic [268]
The answer is <span>The ping command.   The </span><span>tcp/ip troubleshooting command you should  use to determine whether a client and server are communicating with each other is The ping command.  </span><span>The </span>ping command<span> is used to verify that a device can communicate with another on a network.</span>
5 0
3 years ago
When you open your word-processing program, it opens in a<br> field<br> menu
stepan [7]
B- menu...... hope this helps
8 0
3 years ago
Read 2 more answers
Implement the function calcWordFrequencies() that uses a single prompt tonread a list of words (separated by spaces). Then, the
Morgarella [4.7K]
The function it puts those consoles
4 0
3 years ago
How operands are fetched from or stored into memory using different ways?
Mila [183]
<span>The operand is part of the instruction and is fetched from code memory following the instruction opcode.
</span><span>The value is stored in memory, and the specific address is held in a register</span>
6 0
3 years ago
Other questions:
  • Write a class named Taxicab that has three **private** data members: one that holds the current x-coordinate, one that holds the
    9·1 answer
  • When you see ##### in a cell, you should A. increase the cell width. B. increase the cell height. C. decrease the cell width. D.
    14·1 answer
  • Given: an int variable k, an int array current Members that has been declared and initialized, an int variable memberID that has
    11·1 answer
  • Can you structure this code in if-statements?
    15·1 answer
  • My friend has 200 subs and i have only 36 can you help me its ACYT ZR
    9·2 answers
  • What can the tab key do
    10·1 answer
  • During the preventive maintenance phase of a project involving a hydraulic power system, an engineer must change a gasket on a p
    14·1 answer
  • Question: 11
    10·1 answer
  • Juan wrote a loop to print all the prime numbers between 1 and 100. But instead of stopping at 100, it continues on and on forev
    5·1 answer
  • 10.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!