• Home
  • Blog
  • programming problem attached is appendix E for example

programming problem attached is appendix E for example

0 comments

Review the example in Appendix E and the additional examples on pp. 80 & 83 of Prelude to Programming. Complete Programming Problem 2 on p. 109 of Ch. 2 of Prelude to Programming.

 

1. Prompt for and input a saleswoman’s sales for the month (in dollars) and

her commission rate (as a percentage). Output her commission for that

month. Note that you will need to convert the percentage to a decimal.

You will need the following variables:

SalesAmount (a Float) CommissionRate (a Float)

CommissionEarned (a Float)

You will need the following formula:

CommissionEarned = SalesAmount*(CommissionRate/100)

 

2. The manager of the Super Supermarket would like to be able to compute

the unit price for products sold there. To do this, the program should

input the name and price of an item and its weight in pounds and ounces.

Then it should determine and display the unit price (the price per ounce)

of that item and the total cost of the amount purchased. You will need the

following variables:

ItemName (a String) Pounds (a Float) Ounces (a Float)

PoundPrice (a Float) TotalPrice (a Float) UnitPrice (a Float)

You will need the following formulas:

UnitPrice = PoundPrice/16

TotalPrice = PoundPrice*(Pounds + Ounces/16)

 

3: The owners of the Super Supermarket would like to have a program that

computes the monthly gross pay of their employees as well as the

employee’s net pay. The input for this program is an employee ID number,

hourly rate of pay, and number of regular and overtime hours worked.

Gross pay is the sum of the wages earned from regular hours and overtime

hours; overtime is paid at 1.5 times the regular rate. Net pay is gross pay

minus deductions. Assume that deductions are taken for tax withholding

(30 percent of gross pay) and parking ($10 per month). You will need the

following variables:

EmployeeID (a String) HourlyRate (a Float) RegHours (a Float)

GrossPay (a Float) Tax (a Float) Parking (a Float)

OvertimeHours (a Float) NetPay (a Float)

You will need the following formulas:

GrossPay = RegularHours * HourlyRate + OvertimeHours * (HourlyRate * 1.5)

NetPay = GrossPay – (GrossPay * Tax) – Parking

 

4. Shannon and Jasmine bowl as a team. Each of them bowls three games in a

tournament. They would like to know their individual averages for their

three games and the team score (the total of the six games). Allow the user

to input the scores for each player. Output Shannon’s average, Jasmine’s

average, and the team score. You will need the following variables:

Score1 (a Float) Score2 (a Float) Score3 (a Float)

sumShannon (a Float) sumJasmine (a Float) avgShannon (a Float)

avgJasmine (a Float) total (a Float)

 

 

5. Kim wants to buy a car. Help Kim compute the monthly payment on a

loan, given the loan amount, the annual percentage rate of interest, and

the number of monthly payments. The program should allow Kim to input

the loan amount, interest rate, and how many payments she wants to make.

It should then compute and display the monthly payment.

You will need the following variables:

Payment (a Float) LoanAmt (a Float) InterestRate (a Float)

MonthlyRate (a Float) NumberMonths (a Float)

You will need the following formulas:

MonthlyRate = InterestRate/1200

Note: when the user enters InterestRate as a percentage, it must be divided

by 100 to make it a decimal (i.e., 18% = 18/100 = 0.18). The InterestRate

offered by car dealers is an annual rate so this must be divided by 12 to

get the MonthlyRate. The formula given above combines the two steps (i.e.,

annual rate of 18% = 18/100 = 0.18 and the monthly rate is 0.18/12 =

0.015 or 18/(100*12) or 18/1200).

110 Chapter 2 Developing a Program

Payment = LoanAmt * MonthlyRate * (1 + MonthlyRate)^NumberMonths

÷ ((1 + MonthlyRate)^NumberMonths –

About the Author

Follow me


{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}