IRM - Chapter - 6e - 02(4)

2019-04-23 19:55

Savitch

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

Chapter 2

Enter the lethal dose for the mouse in grams 100

Enter the desired weight of the dieter, in grams 45400

For these parameters: mouse weight: 15 grams

lethal dose for the mouse: 100 grams

Dieter weight: 45400 grams The lethal dose in grams of sweetener is: 302667

Lethal number of cans of pop: 864762

Y or y continues, any other character quits y

16

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

Savitch

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

Chapter 2

Enter the weight of the mouse in grams 30

Enter the lethal dose for the mouse in grams 100

Enter the desired weight of the dieter, in grams 45400

For these parameters: mouse weight: 30 grams

lethal dose for the mouse: 100 grams

Dieter weight: 45400 grams The lethal dose in grams of sweetener is: 151333

Lethal number of cans of pop: 432381

17

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

Savitch

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

Chapter 2

Y or y continues, any other character quits q

17:23:56:~/AW$

3. Pay Increase

The workers have won a 7.6% pay increase, effective 6 months retroactively. This program is to accept the previous annual salary, then outputs the retroactive pay due the employee, the new annual salary, and the new monthly salary. Allow user to repeat as desired. The appropriate formulae are:

const double INCREASE = 0.076;

18

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

Savitch

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

Chapter 2

newSalary = salary * (1 + INCREASE);

monthly = salary / 12; retroactive = (salary – oldSalary)/2; The code follows:

//Ch2Prob3.cc

//Given 6 mos retroactive 7.6% pay increase, //input salary

//Output new annual and monthly salaries, retroactive pay #include using namespace std;

const double INCREASE = 0.076;

19

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

Savitch

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

Chapter 2

int main() {

double oldSalary, salary, monthly, retroactive; char ans;

cout << \salary.\

<< \salary, monthly ”

<< “salary, and retroactive pay.\

cin >> oldSalary;//old annual salary salary =

oldSalary*(1+INCREASE);//new annual salary

monthly = salary/12;

20

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


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

下一篇:李春城案

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

马上注册会员

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