PSPD - Lab Assignment 1
PSPD - Lab Assignment 1
1.1 Write a program to assist in the design of a hydroelectric dam. Prompt the user for the height
of the dam and for the number of cubic meters of water that are projected to flow from the top
to the bottom of the dam each second. Predict how many megawatts (1MW = 106 W) of power
will be produced if 90% of the work done on the water by gravity is converted to electrical
energy. Note that the mass of one cubic meter of water is 1000 kg. Use 9.80 meters/second2
as the gravitational constant g . Be sure to use meaningful names for both the gravitational
constant and the 90% efficiency constant. For one run, use a height of 170 m and flow of
1.30 × 103 m3 /s. The relevant formula ( w = work, m = mass, g = gravity, h = height) is: w
= mgh.
1.2 Metro City Planners proposes that a community conserve its water supply by replacing all the
community’s toilets with low-flush models that use only 2 liters per flush. Assume that there
is about 1 toilet for every 3 persons, that existing toilets use an average of 15 liters per flush,
that a toilet is flushed on average 14 times per day, and that the cost to install each new toilet
is $150. Write a program that would estimate the magnitude (liters/day) of the water saved
and the total cost to install new toilets based on the community’s population.
1.3 Write a program that calculates the acceleration (m/s2 ) of a jet fighter launched from an
aircraft-carrier catapult, given the jet’s takeoff speed in km/hr and the distance (meters) over
which the catapult accelerates the jet from rest to takeoff. Assume constant acceleration.
Also calculate the time (seconds) for the fighter to be accelerated to takeoff speed. When you
prompt the user, be sure to indicate the units for each input. For one run, use a takeoff speed
of 278 km/hr and a distance of 94 meters. Relevant formulas ( v = velocity, a = acceleration,
t = time, s = distance)
v = at
1
s = at2
2
1.4 You have saved $500 to use as a down payment on a car. Before beginning your car shopping,
you decide to write a program to help you figure out what your monthly payment will be, given
the car’s purchase price, the monthly interest rate, and the time period over which you will
pay back the loan. The formula for calculating your payment is
iP
payment =
1 − (1 + i)−n
where P = principal (the amount you borrow)
1
i = monthly interest rate 12 of the annual rate)
n = total number of payments
Your program should prompt the user for the purchase price, the down payment, the annual
interest rate and the total number of payments (usually 36, 48, or 60). It should then display
the amount borrowed and the monthly payment including a dollar sign and two decimal places.
1.5 A cyclist coasting on a level road slows from a speed of 10 mi/hr to 2.5 mi/hr in one minute.
Write a computer program that calculates the cyclist’s constant rate of acceleration and deter-
mines how long the cyclist will take to come to rest, given an initial speed of 10 mi/hr. (Hint:
1
Use the equation
vf − vt
a=
t
where a is acceleration, t is time interval, v1 is initial velocity, and vf is final velocity.) Write
and call a function that displays instructions to the program user and a function that computes
a, given t, vf , and vr .
1.6 Write a program to take a depth (in kilometers) inside the earth as input data; compute and
display the temperature at this depth in degrees Celsius and degrees Fahrenheit. The relevant
formulas are
Celsius = 10 (depth) + 20 (Celsius temperature at depth in km)
Fahrenheit = 1.8 (Celsius) + 32
Include two functions in your program. Function celsius at depth should compute and return
the Celsius temperature at a depth measured in kilometers. Function f ahrenheit should
convert a Celsius temperature to Fahrenheit.