IRM - Chapter - 6e - 02(7)

2019-04-23 19:55

Savitch

Problem Solving w/ C++, 6e Instructor’s Resource Guide

Chapter 2

cout.setf(ios::showpoint); cout.setf(ios::fixed); cout.precision(2); // compute payroll do {

cout << \(digits only,”

<< “ no spaces or dashes) \\n”;

cin >> employeeNumber ; cout << “Please the enter hours worked and number “

<< “of employees.” << endl;

cin >> hoursWorked ; cin >> numberDependents;

31

Copyright ? 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Savitch

Problem Solving w/ C++, 6e Instructor’s Resource Guide

Chapter 2

cout << endl;

if (hoursWorked <= 40 ) grossPay = hoursWorked * PAY_RATE;

else {

overTime =

(hoursWorked - 40) * PAY_RATE * OVERTIME_FACTOR;

grossPay = 40 * PAY_RATE + overTime;

}

fica = grossPay * SS_TAX_RATE;

32

Copyright ? 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Savitch

Problem Solving w/ C++, 6e Instructor’s Resource Guide

Chapter 2

incomeTax = grossPay * FedIRS_RATE;

stateTax = grossPay * STATE_TAX_RATE;

netPay =

grossPay - fica - incomeTax

- UNION_DUES - stateTax;

if ( numberDependents >= 3 ) netPay = netPay - HEALTH_INSURANCE;

//now print report for this employee:

cout << \

33

Copyright ? 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Savitch

Problem Solving w/ C++, 6e Instructor’s Resource Guide

Chapter 2

<< employeeNumber << endl;

cout << \hoursWorked << endl;

cout << \<< PAY_RATE << endl;

if (hoursWorked > 40 ) {

cout << \worked: \

<< hoursWorked - 40 << endl;

cout << \premium: \

<< OVERTIME_FACTOR << endl;

34

Copyright ? 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Savitch

Problem Solving w/ C++, 6e Instructor’s Resource Guide

Chapter 2

}

cout << \grossPay << endl;

cout << \<< fica << endl;

cout << \withheld: \

<< incomeTax << endl; cout << \\

if (numberDependents >= 3 ) cout << \Premium withheld: \

<< HEALTH_INSURANCE << endl;

35

Copyright ? 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley


IRM - Chapter - 6e - 02(7).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:李春城案

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: