formatting issue!!!

I'm having trouble formatting my code correctly. When i debug, the formatting is off. How can i fix it?


This is how the output supposed to look like:
 Employee	         ABC
	Hours Worked	        40.00
	Hourly Rate	        8.75
	Total Wages	        350.00
	Deductions   
	Federal Withholding:	63.00
	State Withholding	15.75
	Hospitalization 	25.65
	Union Dues	        7.00
	Total Deductions	111.40
	Net Pay	238.60




1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
 #include<iostream>
#include <iomanip>
#include<string>

using namespace std;

int main(){

string EmployeeInitials;

double HoursWorked, HourlyRate, TotalPay, Deductions;

const double FederalWithholding = 0.18;
const double StateWithholding = 0.045;
const double UnionDues = 0.02;
const double Hospitalisation = 25.65;

cout << "Employee Intials: ";
cin >> EmployeeInitials;
cout << "How Many Hours Did They Work ?: ";
cin >> HoursWorked;
cout << "What Is Thier Hourly rate ?: ";
cin >> HourlyRate;
 

TotalPay = (HoursWorked * HourlyRate);

cout << endl << "Employee: " << EmployeeInitials << endl;
cout << "Hours Worked: " << HoursWorked << endl;
cout << "Hourly rate: " << HourlyRate << endl;
cout << "Total wages: " << TotalPay << endl;
cout << endl << "Deductions" << endl << "----------" << endl;
cout << "Federal Withholding: " << (TotalPay * FederalWithholding) << endl;
cout << "State Withholding: " << (TotalPay * StateWithholding) << endl;
cout << "Union Dues: " << (TotalPay * UnionDues) << endl;
cout << "Hospitalisation: " << Hospitalisation << endl << endl;
 

Deductions = (TotalPay * (FederalWithholding + StateWithholding + UnionDues)) + Hospitalisation;
 

cout << "Total Deductions: " << Deductions << endl;
cout << "Net Pay: " << (TotalPay - Deductions) << endl << endl;
 

system("pause");

return 0;

}
Last edited on
I don't see any formatting.
forgot to add to my code, i'm still having trouble aligning my numbers like said output above.


1
2
3

cout << fixed;
cout << setprecision (2);
setw() would probably do what you need.
http://www.cplusplus.com/reference/iomanip/setw/
@Yanson, thank you.

Although for some reason i'm not able to separate the words with the numbers. Still lost.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
 


        Employee	                      ABC
	Hours Worked	              40.00
	Hourly Rate	               8.75
	Total Wages	               350.00
	Deductions   
	Federal Withholding:	63.00
	State Withholding	       15.75
	Hospitalization 	       25.65
	Union Dues	               7.00
	Total Deductions	       111.40
	Net Pay	                       238.60
Topic archived. No new replies allowed.