#include "stdafx.h"
#include <iostream>
usingnamespace std;
int main(double pay)
{
int days;
float daily;
double total;
cout << "This will display the total salary at the end of the month.\n\n" << endl;
cout.setf(ios_base::fixed , ios_base::floatfield);
cout.precision(2);
cout << "Enter how many days you worked in the month: ";
cin >> days;
cout << "Enter the daily pay in pennies meaning cents: $";
cin >> daily;
cout << "\n\n";
while (days < 1 || days > 31)
{
cout << "Please re-enter the data, days must be greater than 0 and less than or equal to 31.\n\n";
cout << "Enter how many days you worked in the month: ";
cin >> days;
cout << "Enter the daily pay in pennies meaning cents: ";
cin >> daily;
cout << "\n\n";
}
for (int dys = 1 ; dys <= days ; dys++)
{
pay *= 2;
cout << dys << " " << pay;
cout << endl;
}
total =+ pay + pay;
cout << "\n\n";
cout << "Your total salary is $" << total << endl;
cout << endl << "Press ENTER to exit...";
cin.clear();
cin.sync();
cin.get();
return 0;
}
say i enter i worked 3 day and the pay each day was $0.02
its suppose to double so example
day 1 0.02
day 2 0.04
day 3 0.08
your total is 0.14
the pay is suppose to double, but when i run my program the pay is always showing 0.00 for everything.
#include "stdafx.h"
#include <iostream>
usingnamespace std;
int main()
{
int days;
float pay;
double total;
cout << "This will display the total salary at the end of the month.\n\n" << endl;
cout.setf(ios_base::fixed , ios_base::floatfield);
cout.precision(2);
cout << "Enter how many days you worked in the month: ";
cin >> days;
cout << "Enter the daily pay in pennies meaning cents: $";
cin >> pay;
cout << "\n\n";
while (days < 1 || days > 31)
{
cout << "Please re-enter the data, days must be greater than 0 and less than or equal to 31.\n\n";
cout << "Enter how many days you worked in the month: ";
cin >> days;
cout << "Enter the daily pay in pennies meaning cents: ";
cin >> pay;
cout << "\n\n";
}
for (int dys = 1 ; dys <= days ; dys++)
{
pay *= 2;
cout << dys << " " << pay;
cout << endl;
}
total =+ pay + pay;
cout << "\n\n";
cout << "Your total salary is $" << total << endl;
cout << endl << "Press ENTER to exit...";
cin.clear();
cin.sync();
cin.get();
return 0;
}
now when i enter 3 days worked and 0.02 as the pay