If you think your code produces the correct results on the inputs you've tried, maybe you could say what your code does to us, step by step. We could then see where you have a mistaken understanding.
Maybe I am not understanding what you are asking, but this is what my code does right now.
It ask for the number of days worked this month, as long as it is in between 1-31
then it takes the days I put in and first multiplies (0.01*2)*#days I put in and produces a result based off the days I have put in.
If you set something to 0 you can double it for a lifetime - it will never become something different than 0.
Think on using a loop to add the dailySalary to the total earntMoney for each day of work. Then you can adjust the value of dailySalary to be added in every cycle of the loop at your pleasure
{cout << "That is an invalid days selection, please select 1-31: ";
cin >> days;}
firstday=1;
cout<<"Day"<<"\t\t"<<"Amount Earned"<<endl;
cout<<"----------------------------"<<endl;
while(firstday<=days)
{cout<< firstday <<"\t\t\t"<< numPay <<endl;
numPay = numPay *2;
firstday++;
}
total=numPay-0.01;
cout<<" "<<endl;
cout<< fixed << showpoint << setprecision(2);
cout<<" Total Amount To Be Paid Is $"<<"\t"<< total << endl;
cout<<" "<<endl;
return0;
}
I would go through this code and rename a lot of the variables. The computer couldn't care less, but anyone reading it and trying to understand the code (including yourself) is going to get pretty confused because the variable names aren't a good description of what they represent.
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.