This assignment asked me to calculate the salary, and I have done the most of it.
However, the last part of the assignment asked me to display a table of the salary of each day, the total pay at the end of the period. I have worked on this for hours, and have no idea why it doesn't show a correct table. And my text book doesn't say a damn thing about displaying the table.
The program only shows the last day.
I am using Visual C++, thanks a lot!
Code:
#include <iostream.h>
#include <math.h>
#include <iomanip.h>
void main(void)
{
float days;
long double total = 0;
cout << "Please input the number of day for calculation, do NOT enter a value which less than '1'!\n";
cin >> days;
cout << "\n";
while (days < 1)
{
cout << "Warning! You little dork please READ the instruction!\n\n";
cout << "Now, I will give you another chance...enter the number of day again!\n" << endl;
cin >> days;
cout << "\n\n";
}
float penny;
long double pay;
cout << "Please input the pay for the first day (in penny)\n";
cin >> penny;
pay = penny * 0.01;
cout << endl;
cout << setw(6) << "Day";
cout << setw(25) << "Pay for today";
cout << setw(35) << "Total $$$$ you have made" << endl;
cout << "---------------------------------------------------------------------\n";
if (days >= 1)
{
for (int count= 1 ; count <= days; count++);
{
long double payperday;
payperday = pay * (pow (2 , (count - 2)));
total += payperday;
cout << setw(5) << days;
cout << setw(20) << payperday;
cout << setw(30) << total << "\n\n\n"<< endl;
cout << setprecision(1) << setiosflags(ios::dec | ios::fixed) <<"The total pay is $" << total << "\n\n";
}
}
}