I am writing a program that is supposed to calculate how much a person earns in a month if the salary is one penny for the first day, two pennies for the second day, four pennies for the third day, and so on with the daily pay doubling each day the employee works. The program should ask the user for the number of days the employee worked during the month and should display a table showing how much the salary was for each day worked, as well as the total pay earned for the month. Here is the code i have so far:
#include <iostream>
using namespace std;
int main()
{
//Declare variables
int days;
int input;
int cents = 1;
int total =0;
cout<<"\nenter number of days worked: ";
cin>>input;
cin.get();
for(int x = 0; x < input; x++)
{
days = cents;
total += days;
cents *= 2;
}
cout<<"\ntotal pay is :"<<total<<" cents";
for(double x = 0; x < input; x++)
{
cout << "\nday"<<x+1<<" = "<<days<<" cents";
}
system("pause");
return 0;
}
Can someone help me figure out what i am doing wrong?