Comments added...
Code:
#include <cmath> // Not needed in this code
#include <iostream>
double totalPayed(double baseSalary, double bonus1, double bonus2, double bonus3, double bonus4, double bonus5)
{
double sum; // Doesn't hurt, but not needed. You can return the equation result by itself
return sum = ((baseSalary * 5) + bonus1 + bonus2 + bonus3 + bonus4 + bonus5);
}
double payroll(double baseSalary)
{
double payroll;
return payroll = (baseSalary * 5);
}
using namespace std; // this belongs right after the #include statements.
int main()
{
int baseSalary=2000, bonus1=1400, bonus2=600, bonus3=350, bonus4=4500, bonus5=1500, j, sum1, sum2, sum3, sum4, sum5;
switch( (int)totalPayed ) // you can't do this. totalPayed is a function, not a variable.
// All functions need () after their name when you call them.
// You also have to pass the various arguments in that you defined above - six double values.
// Given that you only use integer values, and adding or multiplying them will still result in an integer, why not declare the functions to return int? If you divided them, you'd need doubles.
// Even if you could use totalPayed here (you can't), the result of totalPayed() won't equal 1, 2, 3, etc, so you'll always hit the default statement.
{
case 1:
sum1=baseSalary + bonus1;
break;
case 2:
sum2=baseSalary + bonus2;
break;
case 3:
sum3=baseSalary + bonus3;
break;
case 4:
sum4=baseSalary + bonus4;
break;
case 5:
sum5=baseSalary + bonus5;
break;
default:
for (j=1; j<=6; j++) // This will only run when the other case statements don't. I'm guessing you want to print the results on numbered lines. This won't do it.
{
cout << j << endl;
}
}
cout << "The total payout to all employees is: " << totalPayed(baseSalary, bonus1, bonus2, bonus3, bonus4, bonus5) << endl;
cout << "The payroll is: " << payroll(baseSalary) << endl;
cout << "EmployeeID Base Salary Bonus Total Pay" << endl;
// need return 0 as last statement in main()
}
] // this isn't part of code
That should help some. Fix that stuff before worrying about formatting. Look up setw() for that.