New line plus Wont Display?
Feb 13, 2011 at 5:28am UTC
Revised it once more and I am almost finished, the thing is that it displays everything from regularPay - netPay on the same line? How do I change that? Also, it wont display anything from regularPay on forward without me putting a cin on netPay...?
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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
#include <iostream>
using namespace std;
int main ()
{
int empID; // Data in which user will input info that will be have arithmetic done on it and will be displayed
cout << "empID " ;
cin >> empID;
char payrollType;
cout << "payrollType " ;
cin >> payrollType;
double hoursWorked;
cout << "hoursWorked " ;
cin >> hoursWorked;
double payRate;
cout << "payRate " ;
cin >> payRate ;
int unionCode;
cout << "unionCode " ;
cin >> unionCode;
double regularPay = hoursWorked*payRate;
cout << "regularPay " << regularPay;
double overtimePay;
if (hoursWorked < 40)
overtimePay = 0;
else
overtimePay = payRate * 1.5 * (hoursWorked - 40);
cout << "overtimePay is " << overtimePay;
double grossPay = regularPay + overtimePay;
cout << "grossPay is " << grossPay;
double stateTax;
if ( (grossPay >= 500) && (grossPay <= 1000) )
stateTax = grossPay * .03;
else
stateTax = 0;
if (grossPay > 1000) // If gross pay is > than 1000, 5% is deduced
stateTax = grossPay * .05;
else
stateTax = 0;
cout << "stateTax is " << stateTax;
double federalTax;
if ((grossPay >= 500) && (grossPay <= 1000)) // Federal Tax arithmetic
federalTax = grossPay * .05;
else
federalTax = 0;
if (grossPay > 1000)
federalTax = grossPay * .07;
else
federalTax = 0;
cout << "federalTax is " << federalTax;
double totalTax = stateTax + federalTax;
cout << "totalTax is " << totalTax;
double unionDues;
if (unionCode = 1)
unionDues = 15;
else
unionDues = 35;
if (unionCode = 2)
unionDues = 25;
else
unionDues = 35;
cout << "unionDues is " << unionDues;
double netPay = grossPay - (stateTax + federalTax + unionDues);
cout << "netPay is " << netPay;
cin >> netPay;
return 0;
}
Feb 13, 2011 at 5:32am UTC
add some "endl" in there.
Like:
cout << "overtimePay is " << overtimePay << endl;
endl is like pressing enter in a word processor, it goes to the next line.
If you want to leave a blank line in between, just use it twice :)
--
James
Last edited on Feb 13, 2011 at 5:34am UTC
Feb 13, 2011 at 7:17am UTC
1 2 3 4 5 6 7 8
cout<< "overtimePay is " << overtimePay<< "\n" ;
[code]
or
[code]
cout<< "overtimePay is " << overtimePay;
cout<< "\n" ;
Topic archived. No new replies allowed.