been working on this prog need help getting results to show up correct when compiled

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bossy
    New Member
    • Feb 2010
    • 4

    been working on this prog need help getting results to show up correct when compiled

    Code:
    #include<stdlib.h>
    #include<stdio.h>
    #include<iostream>
    #include<string>
    
    using namespace std;
    
    double getDouble(char prompt[30]);
    int getchar(char prompt[30]);
    void printReport(int);
    
    
    int main()
    {
    	double wages=0.0, interest=0.0, dividends=0.0, otherIncome = 0.0, taxOwed = 0.0, totIncome =0.0;
    	int noDep=0,processed=0;
    	char status[4];
    	
    	double taxes[7][5]={
    		{2.8, 0.0, 2.3, 0.0},
    		{7.5, 5.2, 7.2, 3.8},
    		{9.6, 8.3, 8.9, 7.4},
    		{13.5, 12.2, 13.1, 11.0},
    		{15.5, 14.6, 15.2,13.8},
    		{17.4, 16.3, 17.2, 15.4}
    	};
    	
    	int t;
    	int i;
    	for(t=0; t<7; t++);
    		for(i=0; i<5; i++);
    		{
    			printf("%.2f", taxes[t][i]);
    		}
    	
    	printf("Welcome to the Income Tax Calculator \n\n");
    	printf("Filing Status \n S  = single\n MJ = married filing joint\n MS = married filing seperate\n SH = single head of household\n Q = quit\n");
    	
    	while(strcmp(status, "Q")!= 0)
    	{
    		printf("Enter your filing status: ");
    		scanf_s("%3s", &status,4);
    		//printf("You entered %s\n", status);
    		printf("Enter your amount of Wages:$ ");
    		scanf_s("%lf",&wages);
    		//printf("You entered %lf\n", wages);
    		printf("Enter amount of interest:$ ");
    		scanf_s("%lf",&interest);
    		//printf("You entered %lf\n", interest);
    		printf("Enter amount of Dividends:$ ");
    		scanf_s("%lf",&dividends);
    		//printf("You entered %lf\n", dividends);
    		printf("Enter amount of any other income:$ ");
    		scanf_s("%lf",&otherIncome);
    		//printf("You entered %lf\n", otherIncome);
    		printf("Enter number of Dependents: ");
    		scanf_s("%2d",&noDep);
    		//printf("You entered %d\n", noDep);
    		totIncome = (wages + interest + dividends + otherIncome) - (noDep * 2800);
    		printf("Total Income:$ %.2f\n",totIncome);
    		if(totIncome <= 6000)
    		{
    			printf("Tax owed: %.2f\n",taxes[t][i]);
    		}
    		else if( totIncome > 6001 && totIncome < 10000)
    		{
    				printf("Tax owed: %.2f\n",taxes[t][i]);
    		}
    		else if(totIncome > 10001 && totIncome <= 15000)
    		{
    				printf("Tax owed: %.2f\n",taxes[t][i]);
    		}
    		else if(totIncome > 15001 && totIncome <= 20000)
    		{
    				printf("Tax owed: %.2f\n",taxes[t][i]);
    		}
    		else if(totIncome > 20001 && totIncome <= 25000)
    		{
    				printf("Tax owed: %.2f\n",taxes[t][i]);
    		}
    		else if(totIncome > 25001 && totIncome <= 30000)
    		{
    				 
    				printf("Tax owed: %.2f\n",taxes[t][i]);
    		}
    		else if (totIncome >= 30001)
    		{
    			taxOwed = totIncome * .35;
    			printf("Tax owed: %.2f\n",taxOwed);
    		}
    
    
    	}
    		system("pause");
    		
    		printReport(processed);		
    		
    
    	return 0;
    }
    
    double getDouble(char prompt[30])
    {
        double d;
        char buffer[30];
        printf("%c", prompt);
        gets_s(buffer);
        d = atof(buffer);
        return d;
    }
    int getchar(char prompt[30])
    {
        int i;
        char buffer[30];
        printf("%s", prompt);
        gets_s(buffer);
        i = atoi(buffer);
        return i;
    }
    int getint(char prompt[30])
    {
        int i;
        char buffer[30];
        printf("%d", prompt);
        gets_s(buffer);
        i = atoi(buffer);
        return i;
    }
    
    void printReport(int processed)
    {
    	printf("SINGLE  %d\nMARRIED JOINT	%d\nMARRIED SEPERATE	%d\nSINGLE HEAD  %d\n");
    		    
    
    }
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    Exactly how are the results to appear?

    Comment

    • Banfa
      Recognized Expert Expert
      • Feb 2006
      • 9067

      #3
      And for that matter exactly what output are you getting from the program as it stands.

      You have not posted a full problem description, I full description includes
      • The code
      • The initial conditions for executing the program
      • Any data input the program expects/requires whilst running
      • The expected result of the code
      • The actual result of the code


      So you have only provide 20% of what is needed to best help you, don't be surprised if you only get 20% of an answer.

      Comment

      • bossy
        New Member
        • Feb 2010
        • 4

        #4
        results from program when compiled //notes where problem is

        Code:
         Filing Status
         S  = single
         MJ = married filing joint
         MS = married filing seperate
         SH = single head of household
         Q = quit
        Enter your filing status: s
        Enter your amount of Wages:$ 30000
        Enter amount of interest:$ 0
        Enter amount of Dividends:$ 0
        Enter amount of any other income:$ 500
        Enter number of Dependents: 2
        Total Income:$ 24900.00
        Tax owed: 0.00  //output does not show up, should compute output from taxes table
        Enter your filing status: s
        Enter your amount of Wages:$ 60000
        Enter amount of interest:$ 0
        Enter amount of Dividends:$ 30
        Enter amount of any other income:$ 4000
        Enter number of Dependents: 4
        Total Income:$ 52830.00
        Tax owed: 18490.50//here the output shows up
        Enter your filing status: Q
        Enter your amount of Wages:$ Q
        Enter amount of interest:$ Enter amount of Dividends:$ Enter amount of any other
         income:$ Enter number of Dependents: Total Income:$ 52830.00
        Tax owed: 18490.50
        Press any key to continue . . .
        SINGLE  1245032// should be showing how many of the records were processed for Single
        MARRIED JOINT   1244380// should be showing how many of the records were processed for married joint
        MARRIED SEPERATE  2147348480// should be showing how many of the records were processed for married seperate
        SINGLE HEAD  -858993460// should be showing how many of the records were processed for Single head
        Press any key to continue . . .

        Comment

        • newb16
          Contributor
          • Jul 2008
          • 687

          #5
          printf("SINGLE %d\n whatever whatever %d\n");
          - and no variables to match format specifiers. You need to pass all the result in some form into printReport()

          Comment

          Working...