Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

It has to be done with C++. Description The purpose of this challenge is to use

ID: 3887451 • Letter: I

Question

It has to be done with C++.
Description


The purpose of this challenge is to use the for loops. This challenge uses accumulators and loops.


Requirements


Assume you were offered a job that paid $0.01 on the first day, $0.02 the 2nd day, $0.04 the 3rd day (each day’s income is double the previous day’s income)


Calculate how much you will make in 30 days of work


DO NOT USE


Any power or exponentiation formulas


Sample Interaction / Output


On day 1, you made $0.01 On day 2, you made $0.02 ... After 30 days, you made $10737418.23

The last line above shows the total amount earned having worked 30 days. Make sure your total shows the amount above, not a penny more, not a penny less.


Explanation / Answer

#include <iostream>
#include<iomanip>

int main()
{
double k=0.01;
long double sum=0.0;
int i;
for(i=1;i<=30;i++)
{
sum=sum+k;
  
k=k*2;
  
}
std::cout << std::fixed << std::setprecision(2) <<sum;

return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote