Need Help

been working on this wage calculator for a while and i cannot get it to print the tax and net pay. please someone tell me what ive done wrong.



#include <iostream>
using namespace std;

int main()
{
double wage;
double hours;
double tax_rate;
double Tax;
double gross_pay;
double net_pay;

cout << "Apollyon Bakery\n " << endl;

cout << "Wage Caculator\n " << endl;

cout << "Enter the hourly wage amount :$ ";
cin >> wage;
cout << "Hours worked : ";
cin >> hours;

cout << "You entered the following :" << endl << endl;

cout << "Hourly wage: $ " << wage << endl;
cout << "Hours worked :" << hours << endl;


tax_rate = 0.27 * 100;
cout << "The tax rate is: " << tax_rate << "% " << endl << endl;

gross_pay = wage * hours;
cout << "Gross Pay: $ " << gross_pay << endl;
cin >> gross_pay;

Tax = gross_pay * tax_rate;
cout << "Tax:$ " << Tax << endl;
cin >> Tax;

net_pay = gross_pay - Tax;
cout << "Net Pay: $ " << net_pay << endl;
cin >> net_pay;

system("pause");
return 0;
}
What do you mean? You clearly compute and print something there?

Tip: use code tags when posting. It makes commenting easier. For example:
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
#include <iostream>
using namespace std;

int main()
{
  double wage;
  double hours;
  double tax_rate;
  double Tax;
  double gross_pay;
  double net_pay;

  cout << "Apollyon Bakery\n " << endl;

  cout << "Wage Caculator\n " << endl;

  cout << "Enter the hourly wage amount :$ ";
  cin >> wage;
  cout << "Hours worked : ";
  cin >> hours;

  cout << "You entered the following :" << endl << endl;

  cout << "Hourly wage: $ " << wage << endl;
  cout << "Hours worked :" << hours << endl;


  tax_rate = 0.27 * 100;
  cout << "The tax rate is: " << tax_rate << "% " << endl << endl;

  gross_pay = wage * hours;
  cout << "Gross Pay: $ " << gross_pay << endl;
  cin >> gross_pay;

  Tax = gross_pay * tax_rate;
  cout << "Tax:$ " << Tax << endl;
  cin >> Tax;

  net_pay = gross_pay - Tax;
  cout << "Net Pay: $ " << net_pay << endl;
  cin >> net_pay;

  system("pause");
  return 0;
}

Would you explain lines 33, 37, and 41?
sorry im new to this. I thought i need 33, 37, 41 but looking now i do not. Tax and netpay do not print totals on screen on my end it needs to show that and it does not. what do you mean by code tags?
Last edited on
Tags, see: http://www.cplusplus.com/articles/jEywvCM9/

Have you tried without the unwanted cin's?
yes i took those out and it works but now i cannot get it to use a decimal on the Tax and i cannot get the net pay to do right. been at this for 8 hours.
Your tax_rate is 27.0.

If your wage has no decimals and hours has no decimals, then gross_pay should not have decimals either.

Number with no decimals * 27 probably has no decimals.

Your net_pay = gross_pay - Tax;
Remember that Tax = gross_pay * tax_rate
Lets substitute that in:
net_pay = gross_pay - gross_pay * tax_rate;
and rearrange:
net_pay = gross_pay * ( 1 - tax_rate );
And substitute: tax_rate = 27

1
2
3
net_pay = gross_pay * ( 1 - 27 );
=>
net_pay = -26 * gross_pay;


Is that really how they should be calculated?
Topic archived. No new replies allowed.