Adding pennies together every day they add together HELP
Hi this is a homework assignment, and I dont want anybody to just give it away because I really want to learn my self but I am so stumped.. I understand I need too add the first number of pennies together but I am so confused on how to do this, would i use 2 variables to get this and add them together? But if i did this I dont think it would work in one cout statement since Day 1 should start with 1 penny... so thats why I was thinking I needed to use pennies++; but I have no clue somebody please point me in the right direction here is the code so far
Code:
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main()
{
int totalDays = 0, pennies = 0, days = 1, pay;
do{
cout << "How many days have you worked? ";
cin >> totalDays;
if(totalDays < 1)
cout << endl << "Pick up some hours please...re-enter." << endl
<< endl;
}while(totalDays < 1);
cout << setw(5) << left << endl << "Day #" << setw(17) << right << "Pay" << endl
<< "------------------------" << endl;
while(days <= totalDays)
{
pennies += days;
cout << setw(5) << left << "Day " << days++ << setw(17) << right << pennies;
cout << endl;
}
system("pause");
return 0;
}
it should be 1 penny for day 1
2 pennies for day 2
4 pennies for day 3
8 pennies for day 4 because 1+2+4 plus the 1 penny for that day...and this makes me think like the pennies for all those days have to have seperate variables but I know for sure that thats not what im suppose to do...so confused