This assignment consists of a series of five problems, each worth 20 points, that can be solved
by writing a computer program. For each problem, design an algorithm using a series of
comments and then implement the program using the Ruby language. Use RubyMine to create
a project named Asg4 and, for each problem, add a file to the project named Asg4Exn.rb, where
n is the problem number. For example, the filename of the first problem should be Asg4Ex1.rb.
Within each file, add a comment block at the top that contains the program’s name, your name,
date, the course title, your instructor’s name, the assignment number, the problem number,
and a brief description of the program’s purpose.
Problem #1
Serendipity Booksellers needs a program to determine the cost to ship a
package based on it’s weight. Using the rates shown in the table to the
right, write a program to ask the user for the weight of a package and
display the shipping cost to the user.
If the user enters a value of zero or less for the package weight, inform
the user that the weight is invalid and do not show a cost.
Problem #2
At Serendipity Booksellers, some books can be purchased in bulk at a discount as determined
by the table below. Write a program that asks the user how many books to purchase. If the user
provides a value less than 10, no discounts apply. Inform the user and
end. If the user enters a value of 0 or less, have the program inform him
that the value is invalid and end. Otherwise, have the program ask for
the price of a single book. Then, using the table above, have the
program display the discount percentage. Have the program calculate
and display the cost if no discount were applied, the actual amount of
money saved, and the cost afer applying the discount.
Problem #3
Many companies pay time-and-a-half for employees who work more than forty hours in a given
week. Write a function that asks the user to input the number of hours worked and the hourly
rate, and then calculates and displays the total wages for the week.
Summer 2017 CIS 116 Computer Programming Page 1
Weight Per Pound
< 2 $1.10
2 to 6 $2.20
6+ to 10 $3.70
10+ $3.80
Quantity Discount
10 – 19 20%
20 – 49 30%
50 – 99 40%
100 + 50%
Problem #4
The City of Jerkwater has a policy for drivers cited for speeding within city limits. Violators are
charged $50 plus $5 additional for every mile over the speed limit. If a violator exceeds 90 mph,
an additional $200 is imposed upon the violator. Write a program that asks for the violator’s
speed and the speed limit. The program should then display whether a speeding ticket should
be issued and, if so, the amount of money the violator must pay the city.
Problem #5
Summerdale Condominiums offers properties with various amenities and different costs. The
sales office needs an program to determine the price of a condo depending on the type of view
and parking desired. A condo with a park view has a base price of $150,000. For a golf course
view, the price jumps to $170,000. For a lake view, you have to shell out $210,000. Parking is free
unless the buyer wants an awning, which adds $3,000 to the cost; or an enclosed garage, which
increases the amount by $6,000.
Write a program that asks the user for the type of view they prefer. Then, ask the user if they
want to park in a lot, in a lot with an awning, or an enclosed garage. Based on the user’s choices,
calculate the cost for a condo that meets those conditions. Display a summary to the user that
shows the choices made along with the total cost of the condo based on those choices.
Submitting Your Work
Open Windows Explorer and find the project folder that contains your programs. Compress the