Answer:
#include <iostream>
using namespace std;
int main()
{
int gift=10;
int birthday=12;
int sum=10;
while(gift < 1000){
gift=gift*2;
birthday++;
sum=sum+gift;
}
cout << "The last gift will be given to her at age: "<<birthday << endl;
cout << "Total Amount collected over the years: " << sum << endl;
return 0;
}
Explanation:
Three integer (Numbers that don't have decimal points) variables of are initialized the first is the "gift" while the second is the "birthday".
with the information provided the child is given $10 on her 12th birthday.
The conditional statement here is "until the annual gift exceeded $1000"
which means she'll stop getting the gift when her annual gift exceeds $1000 . I decided to use a while loop but a for loop can also be used.
so while the gift is less than $1000 she'll keep getting it every birthday .
The gift is doubled every birthday and one year is added to her age
In order to know the total amount the child will have received we have to introduce the sum variable.
which adds every gift the child receives.
The last session here signifies how old the child will be when the last amount is given and the total amount the child will have received.