/////////////////////////////////////////////////////////////////////////////////////////////////////
// Program Description:Write a program that calculates the daily //
////pay and total pay of a person who works for a penny the first //
//day and their pay doubles every day after that. The program must //
// calculate the salary and not just output the pay. Use the //
// following variables: //
// //
// Input: days worked //
// Processing: pay cubed + running total //
// Output: pay grid of money earned //
///////////////////////////////////////////////////////////////////////////////////////////////////
#include<iostream>
#include <iostream>
#include <cmath>
using namespace std;
int main ()
{
int days, maxValue = 0;
float wages = 0;
float totalpay = 0;
float runningtotal = 0;
cout <<"Please enter the number of days worked: ";
cin >> maxValue;
cout << "Day \t\tPay \t\tTotal Pay" <<endl;
cout <<"----------------------------------------" <<endl;
for (days = 1; days <= maxValue; days++)
{
if (days==1)
{
wages = .01;
runningtotal = wages;
totalpay = .01;
}
else if (days==2)
{
wages = wages + .01;
runningtotal = wages;
totalpay = .03;
}
else
{
wages = ((wages) * (2));
runningtotal = wages;
totalpay = wages + runningtotal -.01;
}
cout <<days<<"\t\t"<<wages<<"\t\t"<< totalpay<< endl;
}
return 0;
}
No comments:
Post a Comment