# can't get this program to run correctly

• 02-05-2008
Amyaayaa
can't get this program to run correctly
Okay so here is what the program is supposed to do:

“This program estimates the social security deduction (for an
imaginary country) where people who earn less than \$1,500 a week
pay a certain rate (.136) , people who earn \$1,500 or more, pay the same
rate up to \$1,500 and then pay a lower rate (.056) on the additional
income they've earned.

The program will prompt a user for an hourly wage and whether or not the user
works a standard 40 hours a week (as a y/n question).
If the user indicates that he or she works a different number of hours,
they should be promted for how many hours they work

The program then will output the total weekly wage and
the amount of social security deducted.

This is the actual program I have written and I can’t figure out what I am doing wrong:
The program first asks the user to “Enter your hourly wages.” (this is what it is supposed to do)
Then you type an amount in and then it asks “Do you work a standard 40 hour week?”
BUT THEN it asks to press any key to continue and it closes the program!!
Can anyone give me some tips?? I have been at this for about 5 hours now! Here it is:

Code:

``` #include <iostream> using namespace std; int main() {         cout<< "Enter your hourly wages: ";     double hourlywage;     cin>> hourlywage;     cout << "Do you work a standard 40 hour week? (Y/N): " ;     char Answer;     cin>> Answer;     double SocialSecurity;     double weeklywages;         if ( Answer == 'Y') {   ((40 * hourlywage) == weeklywages) ;             (( weeklywages * .136 ) == SocialSecurity) ;        cout<< "Your weekly wages total "<< weeklywages << "." <<endl;     cout<< "The total amount of Social Security deducted is " << SocialSecurity << "."<< endl;    }     else if (Answer = 'N'    {         cout<< "How many hours do you work per week?" ;                double hoursweekly;         cin>> hoursweekly;         double weeklywages2;         (( hourlywage * hoursweekly) = weeklywages2) ;         if (weeklywages2 < 1500) // if their weekly wages are LESS THAN 1500 { ((weeklywages2 * .136) == SocialSecurity) ; cout<<"Your weekly wages total "<< weeklywages2 <<"."<<endl;            cout<<"The total amount of Social Security deducted is " << SocialSecurity << "."<<endl;            }         else if (weeklywages2 >= 1500        {               double amountover;               double SocialSecurity1;               double SocialSecurity2;               double TotalSS;               (( weeklywages2 - 1500) = amountover) ;              (( 1500 * .136 ) == SocialSecurity1) ;              (( amountover * .056 ) = SocialSecurity2) ; (( SocialSecurity1 + SocialSecurity2 ) = TotalSS);              cout <<"Your weekly wages total " << weeklywages2 << "." << endl;              cout <<"The total amount of Social Security deducted is " << TotalSS << "."<< endl;          }                 system("pause");         return 0; }}```
• 02-05-2008
tabstop
The line
Code:

`cin>> Answer;`
only reads in one character, so it leaves the "enter" key waiting around for the next time you call input. Try adding cin.ignore(); before reading the next number.

Edit: I got that backwards -- cin is reading the enter key into Answer (from the last time), so put a cin.ignore() here and see if that helps.
• 02-05-2008
Oldman47
Your bracket is in the wrong place. It should be;

Code:

```     }     cin.get();         return 0; }```
Btw, you're missing closing brackets for certain arguments.

Code:

` else if (weeklywages>2= 1500`
• 02-05-2008
oogabooga
Also, what is this?
Code:

```((40 * hourlywage) == weeklywages) ; (( weeklywages * .136 ) == SocialSecurity) ;```
Presumably you mean
Code:

```weeklywages = 40 * hourlywage; SocialSecurity = weeklywages * .136 = SocialSecurity```