CS 1401 Assignment #3
Date Assigned: Wednesday, February 2, 2005
Due Date: Wednesday, February 9, 2004, before the beginning of
your lab section.
Goals: the main goal of this assignment are to learn how to
implement arithmetic operations in Java.
Points:
This assignment is worth a total of 20 points. No late assignments
will be accepted, but credit will be given for partially completed
assignments turned in on time.
Assignment: One of our alumni suddenly became rich, so he
donated money to build a new Computer Science building. This new
building will
include new TA offices, new faculty offices, and new student lounges.
Two companies will be constructing the building:
an El Paso-based US company will be building the walls,
and a Cd. Juarez-based Mexican company will place hardwood floors in
every room.
To help in constructing this building, we need to
design an application that would,
given the width and depth of every room (in feet):
- compute the floor area of the room (in square feet),
- compute the cost of building this room
by a US contractor by
multiplying its cost-per-square-foot by the room area,
- compute the cost of constructing this room
by a Mexican contractor by first converting the area into square meters and
then multiplying its cost-per-square-meter by the room area in square
meters;
- both companies agrees to provide a 15% discount to the rooms cost
- provided that we help them by designing such an
application.
To earn all of us such a discount,
design an application class that will do the following:
- ask a user (TA of faculty):
- for his or her first name,
- for his or her last name, and
- for the width and depth of the room that this user wants;
- compute:
- the area of the room in square feet,
- its area in square meters,
- the US contractor price (before the discount),
- the Mexican contractor price in pesos (before the discount),
- the Mexican contractor price converted to dollars
(before the discount),
- the US contractor price (after the discount),
- the Mexican contractor price in pesos (after the discount), and
- the overall cost of building this room,
- print a receipt that displays:
- the name of the person who will be using this office,
- the cost of building the walls of this office (before the discount),
- the cost of building the walls of this
office after the 15% discount,
- the cost of the hardwood floor in dollars
(before the discount),
- the cost of the hardwood floor after the 15% discount,
- the total cost of constructing this office.
Keep the price per square foot (at present, $30), the hardwood floor
cost price per square
meter (at present, 2,000 pesos), and the
discount (at present, 15%) as named
constants,
to make it easier to change them later on.
It is also a good
idea to define FEET_TO_METERS = 0.3048 and PESOS_TO_DOLLARS = 0.08941
as named constants.
Reminder: the area of a rectangular room is equal to width *
depth. A 15% discount means that the actual cost is
(1 - 15/100) * original_cost. For example, if the original cost was
$100, after the 15% discount, we only pay $85.
Example:
- For a 10 feet by 15 feet office, the area is 10 * 15 = 150 square
feet.
- So, the cost of building this room (before the discount)
is $150 * 30 = $4,500.
- The area in square meters is 150 sq.ft * 0.3048 ft/m * 0.3048
ft/m = 13.94 sq.m.
- The cost of covering this office with hardwood floor (before the
discount) is
2,000 pesos/sq.m X 13.94 sq.m = 27,880 pesos.
- In dollars, that would be 27,880 pesos * 0.08941 $/peso =
$2,419.38.
- Since you all solved the problem correctly, the contractors give
us a discount. After the 15% discount, the US contractor cost will be
$4,500 * (1 - 0.15) = $3,825.
- After a similar 15% discount, the payment to a Mexican
contractor will be
$2,419.38 * (1 - 0.15) = $2,118.25.
- Thus, the overall cost of building this office and putting
hardwood floor in it is $3,825 + $2,118.25 = $5,943.25.
Deliverables: as announced in the labs and explained in the
handouts given to you in the labs.