# Project Management

Topics: Insurance, Telephone, Personal name Pages: 6 (734 words) Published: October 12, 2013
﻿
Programming Logic and Design, 6th Edition

Chapter 4

Exercises

2. Chocolate Delights Candy Company manufactures several types of candy. Design a flowchart or pseudocode for the following:

a. A program that accepts a candy name (for example, “chocolate-covered blueberries”), price per pound, and number of pounds sold in the average month, and displays the item’s data only if it is a best-selling item. Best-selling items are those that sell more than 2,000 pounds per month.

A sample solution is as follows:

Pseudocode:

start
Declarations
string name
double pricePerPound
double poundsSold
double POUNDS_MIN = 2000
display “Enter the name of the candy: ”
get name
display “Enter the price per pound of this candy in Dollars: ” get pricePerPound
display “Enter the number of pounds of this candy that was sold: ” get poundsSold
if poundsSold > POUNDS_MIN then
display “This is a best selling candy! Name: “, name, “Price per pound: “, pricePerPound, “Pounds sold:”, poundsSold endif
stop

Flowchart:

4. The Summerville Telephone Company charges 10 cents per minute for all calls outside the customer’s area code that last over 20 minutes. All other calls are 13 cents per minute. Design a flowchart or pseudocode for following:

a. A program that accepts data about one phone call: customer area code (three digits), customer phone number (seven digits), called area code (three digits), called number (seven digits), and call time in minutes (four digits). Display the calling number, called number, and price for the call.

A sample solution is as follows:

Pseudocode:

start
Declarations
int custAreaCode
int custPhoneInt
int calledAreaCode
int calledPhoneInt
int minutes
int price
int LOW_RATE = 0.10
int HIGH_RATE = 0.13
int TIME_LIMIT = 20
display “Enter customer area code: ”
get custAreaCode
display “Enter customer phone number (e.g., 555-1212): ” get custPhoneNum
display “Enter the called number area code: ”
get calledAreaCode
display “Enter the called phone number (e.g., 555-1212): ” get calledPhoneNum

if custAreaCode calledAreaCode then
if minutes > TIME_LIMIT then
price = minutes * LOW_RATE
else
price = minutes * HIGH_RATE
endif
else
price = minutes * HIGH_RATE
endif
display “ Customer Called
display Area Code Phone Number Area Code Phone Number Price display custAreaCode, custPhoneNum, calledAreaCode, calledPhoneNum, price stop

Flowchart:

5. The Drive-Rite Insurance Company provides automobile insurance policies for drivers. Design a flowchart or pseudocode for following:

a. A program that accepts insurance policy data including a policy number, customer last name, customer first name, age, premium due month, day and year, and the number of accidents in the last three years. If a policy number entered is not between 1000 and 9999 inclusive, then set the policy number to 0. If the month is not between 1 and 12 inclusive, or the day is not correct for the month (that is, between 1 and 31 for January, 1 and 29 for February, and so on), then set the month, day, and year to 0. Display the policy data after any revisions have been made.

c. A program that accepts policy holders’ data and displays the data for any policy holder who is at least 21 years old.

A sample solution is as follows:

Flowchart:

Pseudocode:

start
Declarations
int policyNumber
int age
int dueMonth
int dueDay
int dueYear
int accidents
string lastName
string firstName
display “Enter your age: ”
get age
if age >= 21 then
display “Enter your policyNumber: ”
get policyNumber
display “Enter your first name: ”
get firstName
display “Enter your last name: ”
get lastName
display “Enter the month...

Please join StudyMode to read the full document