Hey guys and gals. Pretty new to C++. I'm writing a program where a user inputs certain hours and at the very end, it will display how much money you will make. Can't seem to make it put decimals. Code below:
#include <iostream>
#include <cmath>
usingnamespace std;
int main ( )
{
int a, b, c, d, e, sum;
cout << "How many hours did you work on Monday:";
cin >> a;
cout << "How many hours did you work on Tuesday:";
cin >> b;
cout << "How many hours did you work on Wednesday:";
cin >> c;
cout << "How many hours did you work on Thursday:";
cin >> d;
cout << "How many hours did you work on Friday:";
cin >> e;
if (a > 8)
a =(8 * 12.50) + (a % 8 * 18.75);
else
a = a * 12.50;
if (b > 8)
b =(8 * 12.50) + (b % 8 * 18.75);
else
b = b * 12.50;
if (c > 8)
c =(8 * 12.50) + (c % 8 * 18.75);
else
c = c * 12.50;
if (d > 8)
d =(8 * 12.50) + (d % 8 * 18.75);
else
d = d * 12.50;
if (e > 8)
e =(8 * 12.50) + (e % 8 * 18.75);
else
e = e * 12.50;
sum = a + b + c + d + e;
cout << "The total pay for the week is: $";
cout << sum <<endl;
return 0;
}