Site hosted by Angelfire.com: Build your free website today!

Program #10Program #10

C++

K. Dzwonkiewicz

UCMST

With this program we will use

            A conditional statement…the if

A person will need to have their paycheck calculated.

Use the following criteria to determine their pay…

*If a person works 40 hours or less, pay will be rate*hours

*If over 40 hours, pay will be 40*rate+1.5*(hours-40)*rate

*Each person will pay Social Security tax (FICA) of 6% of gross

*Each person will pay Federal Income tax of 33%

*Each person will pay Union dues of $10.00 for men and $12.00 for women

*A penalty will be applied to MALES of $2.25 for possible harassment

NOTES: Put union dues in a constant…

            const float union_m=10.00;

            const float union_f=12.00;

With an if statement C++ does not need a then, it is implied.

            If (hours>40)

                        Pay=40*rate+1.5*……;

With if statements always put the condition that it evaluates in () parentheses.

With if equality use the double equal sign… if (hours==40)…

If you need to do more than one step following an if use braces to bracket all necessary steps.

            If (sex==’m’||sex==’M’)

                        {

                        dues=…;

penalty=…;

}

The OR operator in C++ is the ‘pipes || (above the <enter> key)

The AND operator in C++ is the double amperstand &&.

Sample Run:

                        Enter name: Scat Mann

                        Enter sex:m

                        Enter Rate:$12.50

Enter Hours:44

Sample Output:

 


OUTPUTPAYROLL CALCULATION

Name: Scat Mann         Sex:m

Rate:$12.50       Hours: 44

 

Gross:$575.00               FICA:$34.50                 Fed. Tax:$189.25

Union Dues:$10.00        Penalty:$2.25

 

NET PAY:$338.50

           

Hint: set penalty to 0.00 as the program starts and reset to 2.25 if sex==’m’;