I have copied the below example into my compiler from a book. The example output it shows is:
When I compile the program it gives me scientific notation for the average payroll per department instead of 1029.19. Why's that?
How many departments are there in the company? 7
How many employees are in the company? 45
What is the company's total payroll? 7645.32
The average number of employees per department is 6
The average payroll per department is $1092.19
I'm using the Borland C++ 4.5 complier
// Filename: DIV.CPP
int numDept, totalEmp, avgDept;
float avgPay, pay;
cout <<"How many departments are there in the company? ";
cin >> numDept;
cout <<"How many employees are there in the company? ";
cin >> totalEmp;
cout <<"What is the company's total payroll? ";
cin >> pay;
avgDept = totalEmp / numDept; // Integer division
avgPay = pay / numDept; // Floating-point division;
cout <<"\nThe average number of per department employees "
"is " << avgDept << "\n";
cout <<"The average payroll per department is $"
<< setprecision(2) << avgPay;