11 Replies - 876 Views - Last Post: 29 March 2012 - 04:08 PM Rate Topic: -----

#1 lonniei256  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 26-March 12

tax calculation

Posted 27 March 2012 - 06:40 AM

C++ program that prompts the user to select his/her filling status and enter his/her
income and withheld tax amount (paid tax amount). Your program then calculates the actual tax amount
the user should be paying based on the following tax table:

Tax Bracket Married Filing Jointly Single
10% Bracket $0 – $17,400 $0 – $8,700
15% Bracket $17,401 – $70,700 $8,701 – $35,350
25% Bracket $70,701 – $142,700 $35,351 – $85,650
28% Bracket $142,701 – $217,450 $85,651 – $178,650
33% Bracket $217,451 – $388,350 $178,651 – $388,350
35% Bracket Over $388,350 Over $388,350

Your program then shows the user his/her refund or the amount of tax he/she owes.

+ All output numeric values are right-justified.
+ User must be given a choice whether to repeat/re-run or to terminate the proram.

Below is what I have so far, I am haveing trouble trying to figure out how to set up the tax table so it will give the amount due or refund amount.





[ tax calculator
Algo: ....
*/

#include <iostream>
#include <fstream>
#include <string>

using namespace std;

int main()
{
	//Define variables used in the program
	//variable used to save users income
	string fileStatus;
	//variable used to save withheld tax
	string taxPaid;

	//define output file variable
	ofstream outputFile;

	//initialize file output variable
	outputFile.open("myTaxForm.txt");


	//Define input file varialbe
	ifstream inputFile;
	



	//Implementation of the algorithm defined above
	//Ask user to input file status and withheld tax amount
	cout<<"Enter the file status of the user:"<<endl;
	cin>>fileStatus;

	cout<<"Enter the tax paid amount of the user:"<<endl;
	cin>>taxPaid;

	//Write user’s info to the file
	outputFile <<fileStatus<<"\t"<<taxPaid<<"\n";




return 0;
}
]


:code:

This post has been edited by jimblumberg: 27 March 2012 - 07:21 AM
Reason for edit:: Added missing Code Tags, Please learn to use them.


Is This A Good Question/Topic? 0
  • +

Replies To: tax calculation

#2 lonniei256  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 26-March 12

Re: tax calculation

Posted 27 March 2012 - 07:36 AM

I still haven't figured out how to fit the chart in it.
Was This Post Helpful? 0
  • +
  • -

#3 lonniei256  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 26-March 12

Re: tax calculation

Posted 28 March 2012 - 08:37 PM

how do I get it to sort between married or single?
Was This Post Helpful? 0
  • +
  • -

#4 lonniei256  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 26-March 12

Re: tax calculation

Posted 28 March 2012 - 09:07 PM

This is whar I have so far: [Algo: ....
*/

#include <iostream>
#include <fstream>
#include <string>

using namespace std;

int main()
{
	//Define variables used in the program
	//variable used to save users income
	string fileStatus;
	//variable used to save withheld tax
	string taxPaid;

	//define output file variable
	ofstream outputFile;

	//initialize file output variable
	outputFile.open("myTaxForm.txt");


	//Define input file varialbe
	ifstream inputFile;
	



	//Implementation of the algorithm defined above
	//Ask user to input file status and withheld tax amount
	cout<<"Enter the file status of the user:"<<endl;
	cin>>fileStatus;

	cout<<"Enter the tax paid amount of the user:"<<endl;
	cin>>taxPaid;

	//Write user’s info to the file
	outputFile <<fileStatus<<"\t"<<taxPaid<<"\n";
	//variable used from tax table
	cout<<"enter tax paid from table:"<<endl;
	cin>>tax ;
	
	cout<<"Type your tax paid:";
	cin>>tax ;
	if( tax  > 0){
		cout<<"Too good to be true!"<<endl;
	}
	else{  //tax paid <= 17,400
	
		if( tax  >= 17,400){
			cout<<"10%"<<endl;
		}
		else{
			if( tax >=70,700){  //tax paid <70,700 && taxpaid >= 17,401
				cout<<"15%"<<endl;
			}
			else{
				if(tax >=70,701){
					cout<<"142,700"<<endl;
				}
				else{
					if( tax >= 217,450){
						cout<<"28%"<<endl;
					}
					else{
						cout<<"388,350"<<endl;
					}
				}
			}
		}
	}
	*/
	if(tax > 0){
		cout<<"Too good to be true."<<endl;
	}
	else if(tax >= 17,400){
		cout<<"10%"<<endl;
	}
	else if( tax >= 70,700){
		cout<<"15%"<<endl;
	}
	else if( tax >= 142,700){
		cout<<"25%"<<endl;
	}
	else if(tax >= 217,450){ //  217,450 <= tax < 142,700
		cout<<"28%"<<endl;
	}
	/*
	else if(tax >= 0){ ///case?? 0 <= tax < 388,350		cout<<"33%"<<endl;
	}
	*/
	else{  // tax < 388,350
		cout<<"35%"<<endl;

}
	


return 0;
}

] what am I doing wrong?

:code:

This post has been edited by jimblumberg: 29 March 2012 - 05:35 AM
Reason for edit:: Added missing Code Tags, Please learn to use them.

Was This Post Helpful? 0
  • +
  • -

#5 jimblumberg  Icon User is offline

  • member icon

Reputation: 3048
  • View blog
  • Posts: 9,282
  • Joined: 25-December 09

Re: tax calculation

Posted 29 March 2012 - 05:41 AM

Quote

what am I doing wrong?


The first thing is you did not use code tags when posting code. :code:


What exactly is your problem? Does the code compile without errors? If not post the complete error messages, exactly as they appear in your development environment. Note: this code will not compile without errors as presented. So post the error messages.

Jim

This post has been edited by jimblumberg: 29 March 2012 - 05:42 AM

Was This Post Helpful? 0
  • +
  • -

#6 lonniei256  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 26-March 12

Re: tax calculation

Posted 29 March 2012 - 07:36 AM

Corrections made and program runs but still does not give correct info from table01 #include <iostream>
02 #include <fstream>
03 #include <string>
04
05 using namespace std;
06
07 int main()
08 {
09 //Define variables used in the program
10 //variable used to save users income
11 string fileStatus;
12 //variable used to save withheld tax
13 string taxPaid;
14
15 //define output file variable
16 ofstream outputFile;
17
18 //initialize file output variable
19 outputFile.open("myTaxForm.txt");
20
21
22 //Define input file varialbe
23 ifstream inputFile;
24
25
26
27
28 //Implementation of the algorithm defined above
29 //Ask user to input file status and withheld tax amount
30 cout<<"Enter the file status of the user:"<<endl;
31 cin>>fileStatus;
32
33 cout<<"Enter the tax paid amount of the user:"<<endl;
34 cin>>taxPaid;
35
36 //Write user’s info to the file
37 outputFile <<fileStatus<<"\t"<<taxPaid<<"\n";
38 //variable used from tax table
39 cout<<"enter tax paid from table:"<<endl;
40 cin>>tax ;
41
42 cout<<"Type your tax paid:";
43 cin>>tax ;
44 if( tax > 0){
45 cout<<"Too good to be true!"<<endl;
46 }
47 else{ //tax paid <= 17,400
48
49 if( tax >= 17,400){
50 cout<<"10%"<<endl;
51 }
52 else{
53 if( tax >=70,700){ //tax paid <70,700 && taxpaid >= 17,401
54 cout<<"15%"<<endl;
55 }
56 else{
57 if(tax >=70,701){
58 cout<<"142,700"<<endl;
59 }
60 else{
61 if( tax >= 217,450){
62 cout<<"28%"<<endl;
63 }
64 else{
65 cout<<"388,350"<<endl;
66 }
67 }
68 }
69 }
70 }
71 */
72 if(tax > 0){
73 cout<<"Too good to be true."<<endl;
74 }
75 else if(tax >= 17,400){
76 cout<<"10%"<<endl;
77 }
78 else if( tax >= 70,700){
79 cout<<"15%"<<endl;
80 }
81 else if( tax >= 142,700){
82 cout<<"25%"<<endl;
83 }
84 else if(tax >= 217,450){ // 217,450 <= tax < 142,700
85 cout<<"28%"<<endl;
86 }
87 /*
88 else if(tax >= 0){ ///case?? 0 <= tax < 388,350 cout<<"33%"<<endl;
89 }
90 */
91 else{ // tax < 388,350
92 cout<<"35%"<<endl;
93
94 }
95
96
97
98 return 0;
99 }

.[
Was This Post Helpful? 0
  • +
  • -

#7 jimblumberg  Icon User is offline

  • member icon

Reputation: 3048
  • View blog
  • Posts: 9,282
  • Joined: 25-December 09

Re: tax calculation

Posted 29 March 2012 - 07:40 AM

Please post the code without line numbers in code tags. :code:

Jim
Was This Post Helpful? 0
  • +
  • -

#8 lonniei256  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 26-March 12

Re: tax calculation

Posted 29 March 2012 - 07:48 AM

As you wish. code without line numbers.
[
#include <iostream> 
	#include <fstream> 
	#include <string> 
	  
	using namespace std; 
	  
	int main() 
	{ 
	    //Define variables used in the program 
	    //variable used to save users income 
	    string fileStatus; 
	    //variable used to save withheld tax 
	    string taxPaid; 
	  
	    //define output file variable 
	    ofstream outputFile; 
	  
	    //initialize file output variable 
	    outputFile.open("myTaxForm.txt"); 
	  
	  
	    //Define input file varialbe 
	    ifstream inputFile; 
	      
	  
	  
	  
	    //Implementation of the algorithm defined above 
	    //Ask user to input file status and withheld tax amount 
	    cout<<"Enter the file status of the user:"<<endl; 
	    cin>>fileStatus; 
	  
	    cout<<"Enter the tax paid amount of the user:"<<endl; 
	    cin>>taxPaid; 
	  
	    //Write user’s info to the file 
	    outputFile <<fileStatus<<"\t"<<taxPaid<<"\n"; 
	    //variable used from tax table 
	    cout<<"enter tax paid from table:"<<endl; 
	    cin>>tax ; 
	      
	    cout<<"Type your tax paid:"; 
	    cin>>tax ; 
	    if( tax  > 0){ 
	        cout<<"Too good to be true!"<<endl; 
	    } 
	    else{  //tax paid <= 17,400 
	      
	        if( tax  >= 17,400){ 
	            cout<<"10%"<<endl; 
	        } 
	        else{ 
	            if( tax >=70,700){  //tax paid <70,700 && taxpaid >= 17,401 
	                cout<<"15%"<<endl; 
	            } 
	            else{ 
	                if(tax >=70,701){ 
	                    cout<<"142,700"<<endl; 
	                } 
	                else{ 
	                    if( tax >= 217,450){ 
	                        cout<<"28%"<<endl; 
	                    } 
	                    else{ 
	                        cout<<"388,350"<<endl; 
	                    } 
	                } 
	            } 
	        } 
	    } 
	    */ 
	    if(tax > 0){ 
	        cout<<"Too good to be true."<<endl; 
	    } 
	    else if(tax >= 17,400){ 
	        cout<<"10%"<<endl; 
	    } 
	    else if( tax >= 70,700){ 
	        cout<<"15%"<<endl; 
	    } 
	    else if( tax >= 142,700){ 
	        cout<<"25%"<<endl; 
	    } 
	    else if(tax >= 217,450){ //  217,450 <= tax < 142,700 
	        cout<<"28%"<<endl; 
	    } 
	    /* 
	    else if(tax >= 0){ ///case?? 0 <= tax < 388,350        cout<<"33%"<<endl; 
	    } 
	    */
	    else{  // tax < 388,350 
	        cout<<"35%"<<endl; 
	  
	} 
	      
	  
	  
	return 0; 
	}

]

MOD EDIT: ADDED MISSING CODE TAGS!!
LIKE THIS:
:code:

This post has been edited by jimblumberg: 29 March 2012 - 07:57 AM
Reason for edit:: Added missing Code Tags, Please learn to use them.

Was This Post Helpful? 0
  • +
  • -

#9 vividexstance  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 390
  • View blog
  • Posts: 1,348
  • Joined: 31-December 10

Re: tax calculation

Posted 29 March 2012 - 07:50 AM

You still didn't put the code in CODE-tags. Either way, is there a question? Does the program compile? If not, what warnings/errors are you getting? If it does compile, what does it output when you run it? What is the "expected" output?
Was This Post Helpful? 0
  • +
  • -

#10 jimblumberg  Icon User is offline

  • member icon

Reputation: 3048
  • View blog
  • Posts: 9,282
  • Joined: 25-December 09

Re: tax calculation

Posted 29 March 2012 - 08:02 AM

Where are your code tags????

Were are your error messages???

Where is your questions???


Your code has several errors. Here they are:

Quote

main.cpp||In function ‘int main()’:|
main.cpp|40|error: ‘tax’ was not declared in this scope|
main.cpp|71|error: expected primary-expression before ‘/’ token|
main.cpp|72|error: expected primary-expression before ‘if’|
main.cpp|72|error: expected ‘;’ before ‘if’|
main.cpp|75|error: ‘else’ without a previous ‘if’|
||=== Build finished: 5 errors, 0 warnings ===|


When you have compile errors post the complete error messages exactly as they appear in your development environment.

Do you need help deciphering your error messages?

Please show the line in question for the first error listed above.


Jim
Was This Post Helpful? 0
  • +
  • -

#11 r.stiltskin  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1831
  • View blog
  • Posts: 4,927
  • Joined: 27-December 05

Re: tax calculation

Posted 29 March 2012 - 08:28 AM

You need to start over from the beginning because it's apparent that you don't understand the assignment.

The tax table doesn't give you the amounts that you are supposed to print. The tax table gives you a set of rules that you are supposed to use to calculate the amount of tax.

You have to:
input the amount of the taxpayer's income
input the taxpayer's status
calculate (using the applicable column of the table) and then output the amount of tax

Here's your tax table (just the Married status portion to simplify the explanation):
Tax Bracket    Married Filing Jointly
10% Bracket    $0 – $17,400
15% Bracket    $17,401 – $70,700
25% Bracket    $70,701 – $142,700
28% Bracket    $142,701 – $217,450
33% Bracket    $217,451 – $388,350
35% Bracket    Over $388,350


Here's what it means:
The amount of the taxpayer's income that falls within the range listed under their filing status is taxed at the rate listed in the first column. A taxpayer's income can fall into more than one range. For example, a taxpayer who has $25,000 of income will be taxed at two different rates; this taxpayer will have two partial taxes which have to be combined into his total tax. Here's how:
If the taxpayer's income is 25000, this taxpayer has 17400 of income in the first bracket, and this taxpayer also has 25000 - 17400 = 7600 of income in the second bracket. So this taxpayer pays:
first partial tax: 17400 x 10% = 1740
second partial tax: 7600 x 15% = 1140
                                 ----
total tax                        2880


So, a taxpayer with income of 400000 has 6 partial taxes because part of his income falls into every bracket.

Back to work.
Was This Post Helpful? 0
  • +
  • -

#12 lonniei256  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 26-March 12

Re: tax calculation

Posted 29 March 2012 - 04:08 PM

Tried again, it compiles:
Algo . . .;
//Select user filling status
//Enter his/her income and withholding tax amount
//Calculate the tax amount the user should be paying based on the tablel
//Show the tax amount he/she owes
//All output numeric values are "right-justified"
//User must be given option whether to rerun or terminate program
*/

#include <iostream>

using namespace std;

int main()
{
	//Define variables
	char married= 'a' || 'A',
		single= 'b' || 'B',
		status;
	int input;
	//Step 1: display menu
	cout<<"are you married or single"<<endl;
	cout<<"exit prog with x\n"<<endl;

	//step 2: status:
	
	cout<<"\nA) Married Filling Jointly"<<endl;
	cout<<"\nB) Single"<<endl;

	cin >> status;

	switch (status){
	case 'a':
	case 'A':

		cout<<"\n married."<<endl;
		cout<<"\n what is your income?"<<endl;
		cin>> input;

		if (input > 388,350){
			cout<<"you will pay 35% tax"<<endl;
			return 0;
		}
		if (input >= 217,451 && input <=388,350){
			cout<<" you will pay 33% tax"<<endl;
			return 0;
		}
		if (input >= 142,701 && input <=217,450){
			cout<<" you will pay 28% tax"<<endl;
			return 0;
		}
		if (input >= 70,701 && input <=142,700){
			cout<<" you will pay 25% tax"<<endl;
			return 0;
		}
		if (input >= 17,401 && input <=70,700){
			cout<<" you will pay 15% tax"<<endl;
			return 0;
		}
		if (input >= 0 && input <=17,700){
			cout<<" you will pay 10% tax"<<endl;
			return 0;
		}


	}

	switch (status){
	case 'b':
	case 'B':
		cout<<"\n single."<<endl;
		 cout<<"\n what is your income"<<endl;
		 cin>> input;
		 
		 if (input >388,350){
			 cout<< " you will pay 35% tax"<<endl;
		 }
		 else if (input >=178,651 && input <=388,350){
			 cout<< " you will pay 33% tax"<<endl;
		 }
		 else if (input >=85,651 && input <=178,650){
			 cout<< " you will pay 28% tax"<<endl;
		 }
		 else if (input >=35,351 && input <=85,650){
			 cout<< "you will pay 25% tax"<<endl;
		 }
		 else if (input >=8,701 && input <=35,350){
			 cout<< "you will pay 15% tax"<<endl;
		 }
		 if (input >=0 && input <=8,700){
			 cout<< "you will pay 10% tax"<<endl;
		 }
		 break;
	}
	

	/*
	if (status == 'A'){
	if (income >=0 && income <= 17,400){
	cout<< "you will pay 10% tax";
	}
	else if ( income >=17,401 && income <=70,700){
	cout<< " you will pay 15% tax";
	}
	else if ( income >=70,701 && income <=142,700){c
	out<< " you will pay 25% tax";
	}
	else if (income >= 142,701 && income <=217,450)
	{cout<<" you will pay 28% tax";
	}
	else if (income >= 217,451 && income <=388,350){
	cout<< " you will pay 33% tax";
	}
	else if (income > 388,350){
	cout << " you will pay 35% tax";
	}
	

	if (status== 'single')
	{
		if (income >=0 && income <=8,700){
		cout<< "you will pay 10% tax";
		}
		else if (income >=8,701 && income <=35,350){
		cout<< "you will pay 15% tax";
		}
		else if (income >=35,351 && income <=85,650){
		cout<< "you will pay 25% tax";
		}
		else if (income >=85,651 && income <=178,650){
		cout<< " you will pay 28% tax";
		}
		else if (income >=178,651 && income <=388,350){
		cout<< " you will pay 33% tax";
		}
		else if (income >388,350){
		cout<< " you will pay 35% tax";
		}
		else
		{
		cout<< "retype your income correctly";
		}
	}

	*/
            

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1