New to Prog. C++

Hello, am new in programming (C++). This assignment was given in class. I try to code but am not getting right answer. Can someone help code this?

Ques 1: Write a program that accept the gross amount from the user and compute his/her take home pay given the following taxes.
Tax 1 =5%
Tax 2 =$100
Tax 3 =12%

Ques 2: Write a program that accepts temperature reading in Fahrenheit and converts the readings to Celsius
oC = 5/9 * (oF - 32).


Question 1 code below:

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
  #include <iostream>

using namespace std;

int net;
int gross;
int totaltax;
int main()
{
   cout << "Please input your salary " <<endl;
   cin >> gross;

   int tax1 = (gross/100) * 5;

   cout << "First Tax rate @ 5% = " << tax1 <<endl;

   int tax2 = 100;

   cout << "Second Tax is @ 100 = " << tax2 <<endl;

   int tax3 = (gross-tax1-tax2)/100 * 12;

   cout << "Third Tax is @ 12% = " << tax3 <<endl;

            net = gross - totaltax;

   cout << "Your net salary is = " << net <<endl;




    return 0;
}
On line 25, you never assign the totaltax a value. After calculating tax3 and before calculating net, you need to set totaltax equal to the sum of the three taxes.
line 13 and 21, be careful of integer division.
e.g. what's 40 divided by 100? To a computer this is equal to zero.
Topic archived. No new replies allowed.