Hey guys I had to write a program for a C++ class im in, There is 3 different outputs to perform (two early exits) and both of those work great but running the problem all the way though i do not get the follow results. Any assitance would be appreciate because I am stumped.
Input:
Exemptions : 5
AGI : 258250
Status: 2
Output
Line 2 = 18250
Line 3 = 258250
Line 4 = 250200
Line 5 = 8050
Line 6 = 4
Line 7 = 0.08
Line 8 = 1460
Line 9 = 486.67
Line 10 = 17763.33
Code
Code:
#include <iostream> // for I/O
#include <iomanip> // for formating output
#include <cmath> // for math fuctions
#include <cctype> // for Common Character Functions
using namespace std;
//Global Constants
double EXEMPTION = 3650 ;
double SINGLE = 166800 ;
double MAR_OR_WIDOW = 250200 ;
double HEAD_OF_HOUSE = 208500 ;
double MAR_SEP = 125100 ;
double MAR_SEP_LINE6 = 1250 ;
double MAR_SEP_LINE6_YES = 61250 ;
double STATUS_LINE6 = 2500 ;
double STATUS_LINE6_YES = 122500 ;
double LINE6 = 2433 ;
double PERCENT_LINE7 = .02 ;
int THREE = 3 ;
//Function for No on Line 6
int line6 (double filingStatus, double lineFive, int lineSix)
{
if (filingStatus == 5)
{
lineSix = (lineFive / MAR_SEP_LINE6) ;
ceil (lineSix) ;
}
else
{
lineSix = (lineFive / STATUS_LINE6) ;
ceil (lineSix) ;
}
return lineSix ;
}
//Function Main calculates Sphere Volume and calls output
int main()
{
// Local Variables
double numExemp ;
double adjGross ;
double filingStatus ;
double incomeLimit ;
double lineTwo ;
double lineFive ;
int lineSix ;
double lineSeven ;
double lineEight ;
double lineNine ;
double lineTen ;
// Prompt for and read in Number of Exemptions
cout << " Enter the number of exemptions claimed: " ;
cin >> numExemp ;
cout << endl << endl ;
// Prompt for and read in Adjusted Gross Income
cout << " Enter your Adjusted Gross Income (1040, line 38): " ;
cin >> adjGross ;
cout << endl << endl ;
// Prompt for and Read in Filing Status
cout << " 1 - Single" << endl ;
cout << " 2 - Married, Filing Jointly" << endl ;
cout << " 3 - Head of Household" << endl ;
cout << " 4 - Qualifying Widow(er)" << endl ;
cout << " 5 - Married, Filing Separately" << endl ;
cout << " Enter your filing status from above (1-5): " ;
cin >> filingStatus ;
cout << endl << endl ;
//Determine Income Limit
if (filingStatus == 1)
incomeLimit = SINGLE ;
else if (filingStatus == 2)
incomeLimit = MAR_OR_WIDOW ;
else if (filingStatus == 3)
incomeLimit = HEAD_OF_HOUSE ;
else if (filingStatus == 4)
incomeLimit = MAR_OR_WIDOW ;
else if (filingStatus == 5)
incomeLimit = MAR_SEP ;
// Calculate Line 2 (total exemptions)
lineTwo = (EXEMPTION * numExemp) ;
//Display Output Heading
cout << setw(45) << "Deduction for Exemptions Worksheet" << endl << endl;
// Test for Early Exit Condition
if (adjGross < incomeLimit)
{
cout << " 1. AGI is not over filing status amount" << endl ;
cout << " 2. Exemptions claimed ( " << numExemp << " x 3650):" << setw(19) << lineTwo << endl << endl ;
cout << " ***Enter amount from worksheet line 2 on form 1040 ling 42" << endl << endl ;
system("PAUSE") ;
return 1 ;
}
else if (adjGross > incomeLimit)
{
cout << " 1. AGI is over filing status amount" << endl ;
cout << " 2. Exemptions claimed ( " << numExemp << " x 3650):" << setw(22) << fixed << setprecision (2) << lineTwo << endl << endl ;
}
// Display Line 3
cout << " 3. Adjusted gross income:" << setw(31) << adjGross << endl;
// Display Line 4
cout << " 4. Filing status (" ;
if (filingStatus == 1)
cout << "single):" << setw(30) << incomeLimit << endl ;
else if (filingStatus == 2)
cout << "married joint):" << setw(23) << incomeLimit << endl ;
else if (filingStatus == 3)
cout << "head of house):" << setw(23) << incomeLimit << endl ;
else if (filingStatus == 4)
cout << "widow(er)):" << setw(27) << incomeLimit << endl ;
else if (filingStatus == 5)
cout << "married separate):" << setw(20) << incomeLimit << endl ;
// Display Seperator
cout << " ---------------------------------------------------------" << endl ;
// Calculate Line 5 (Amount Over Filing Status)
lineFive = (adjGross - incomeLimit) ;
// Display Line Five (Amount Over Filing Status)
cout << " 5. Amount over:" << setw(41)<< lineFive << endl << endl ;
// Format Display for 0 Decimal Places
cout << fixed << setprecision (0);
// Dixplay and Calculate Line 6
if (filingStatus == 5)
{
if (lineFive > MAR_SEP_LINE6_YES)
{
lineSix = (numExemp * LINE6) ;
cout << " 6. Excemptions allowed (" << numExemp << " X 2433):" << setw(23) << lineSix << endl << endl ;
cout << " ***Enter amount from worksheet line 6 on form 1040 line 42" <<endl << endl ;
system("PAUSE") ;
return 6 ;
}
else
{
line6 (filingStatus, lineFive, lineSix) ;
cout << " 6. Division results:" << setw(36) << lineSix << endl ;
}
}
else
{
if (lineFive > STATUS_LINE6_YES)
{
lineSix = (numExemp * LINE6) ;
cout << " 6. Excemptions allowed (" << numExemp << " X 2433):" << setw(23) << lineSix << endl << endl ;
cout << " ***Enter amount from worksheet line 6 on form 1040 line 42" << endl << endl;
system("PAUSE") ;
return 6 ;
}
else
{
line6 (filingStatus, lineFive, lineSix) ;
cout << " 6. Division results:" << setw(36) << lineSix << endl ;
}
}
// Format Display for 2 Decimal Places
cout << fixed << setprecision (2);
// Display Seperator
cout << " ---------------------------------------------------------" << endl ;
// Calculate Line Seven
lineSeven = (lineSix * PERCENT_LINE7) ;
// Display Line Seven
cout << " 7. Multiply Line 6 by 2%:" << setw(31) << lineSeven << endl ;
// Calculate Line Eight
lineEight = (lineTwo * lineSeven) ;
// Display Line Eight
cout << " 8. Multiply line 2 by line 7:" << setw(27) << lineEight << endl ;
// Calculate Line Nine
lineNine = (lineEight / THREE) ;
// Display Line Nine
cout << " 9. Divide line 8 by 3.0:" << setw(32) << lineNine << endl ;
// Display Seperator
cout << " ---------------------------------------------------------" << endl ;
// Calculate Line Ten
lineTen = (lineTwo - lineNine) ;
// Display Line Ten
cout << " 10. Subtract line 9 from line 2:" << setw (25) << lineTen << endl << endl ;
cout << " ***Enter amount from worksheet line 10 on Form 1040 line 42" << endl ;
//Pauses Program so output can be seen
cout << endl << endl ;
system("PAUSE") ;
return 0 ;
}