please help

vgvvvvvvvvvvvv
Last edited on
We're not here to do your homework. This forum is for those who need help with their code, not entire solutions.

Try doing it yourself and if you get stuck, post the code that you have with questions on what you don't understand
Last edited on
You have forgotten something.........



Your code, with code tags please - the <> button on the right.

And compiler output, if it doesn't compile.
this is what i had, but i figured it is completely wrong. i shouldn't use the if statements.

#include <iostream>
#include <math.h>
#include <string>

using namespace std;


int main()
{

// declare variables
int sinc; // Single income
int sinc; // Married Filing Jointly income
int hinc; // Head of Household income


double tax;

// get input from user
cout << "if you are single, how much do you earn? if not enter -1";
cin >> sinc;

cout << "if you are Married Filing Jointly, how much do you earn? if not enter -1";
cin >> minc;

cout << "if you are / Head of Household, how much do you earn? if not enter -1";
cin >> hinc;



// do computations (processing)

if (sinc > 0 && sinc <= 40,000)
{
inc = "1 accidents";
inc = .10;
}

else if (sinc > 40,000 && sinc <= 300,000)
{
asr = "2 accidents";
asrp = .25;
}
else if (sinc > 300,000)
{
asr = "3 accidents";
asrp = .35;
}
if (minc > 0 && minc <= 100,000)
{
asr = "1 accidents";
asrp = .10;
}

else if (minc > 100,000 && minc <= 300,000)
{
asr = "2 accidents";
asrp = .25;
}
else if (minc > 300,000)
{
asr = "3 accidents";
asrp = .35;

}
if (hinc > 0 && hinc <= 50,000)
{
asr = "1 accidents";
asrp = .10;
}

else if (hinc > 50,000 && hinc <= 300,000)
{
asr = "2 accidents";
asrp = .25;
}
else if (hinc > 300,000)
{
asr = "3 accidents";
asrp = .35;
}

cout << " can not insure" << endl;
system("PAUSE");
return 0;
}

// do processing

tax = income * sinc;

tax = income * minc;

tax = income * hinc;

// output results


system("PAUSE");
return 0;
}
Please use the <> source code format button -.-
Also with a quick look at the program,

1
2
int sinc; // Single income 
int sinc; // Married Filing Jointly income  


You made a typo and declared the same variable twice.
Last edited on
i need help with the second step

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

using namespace std;

int main()
{
	// declare data variables
	
	double r; // rate
	double tax; //tax
	double inc; //income

	


	// get input from user
	cout << "Enter rate: " << endl;
	cin >> r;

	cout << "Enter income: " << endl;
	cin >> inc;


	cout << endl << endl << endl;

	// do processing
	tax =  inc * r;

	// output results
	cout << "The area is ";
	cout << tax << endl;

		
	system("PAUSE");
	return 0;
}
Last edited on
Ali's midterm?
yes
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
83
84
85
86
87
88
89
90
91
#include <iostream>
using namespace std;


double tax(double income, double r)
{
    return income * r;
}


double perc_tax(double income, char n)
{
    double perc;
    if(n=='s')
    {
        if(income<40000){
            perc=0.10;}
        else if (income>40000 && income<300000)
            perc = 0.25;
        else if (income>300000)
            perc=0.35;
     }
    
    
    else if(n=='m')
    {
        if(income<100000){
            perc=0.10;}
        else if (income>100000 && income<300000)
            perc = 0.25;
        else if (income>300000)
            perc=0.35;
     }
    
    else if(n=='h')
    {
        if(income<50000){
            perc=0.10;}
        else if (income>50000 && income<300000)
            perc = 0.25;
        else if (income>300000)
            perc=0.35;
     }
    return perc;
}

double deductDependants(double tax, int depCount)
{
double 
    for(int i=1;i<=depCount;i++)
    {
        tax = tax-500;
return (tax);
    }
}





int main()
{
 
    double income,paid,deductedTax,refund,r;
    char filling;
    int depCount;
    
    cout<<"Enter Income \n";
    cin>>income;
    cout<<"Enter the number of your dependants\n";
    cin>>depCount;
    cout<<"Enter 's' if single, 'm' if married, 'h' if head of household.\n";
    cin>>filling;
    
    r = perc_tax(income,filling );
   
   paid = tax(income,r);
   deductedTax = deductDependants(paid,depCount);
   refund =deductedTax-paid;
   
   cout<<"income: "<<income<< " paid: "<<paid<< " refund: "<<refund<<" deductedTax: "<<deductedTax<<" depCount: "<<depCount;

    if(refund<0)
       cout<<"\nYou are Entitles to a refund of $"<<paid-deductedTax;
   else if (refund>0)
       cout<<"\nYou are Entitles to a refund of $"<<refund;
   else
       cout<<"\nYou are NOT Entitled to a refund";
   
   
}



made a faulty function deductDependants() and some other errors but hope it gives u a clue to the real thing
Last edited on
thank you, BridgesBenghazi!
Topic archived. No new replies allowed.