tugas_method2
-
Upload
alan-dtodz-crew -
Category
Documents
-
view
216 -
download
0
Transcript of tugas_method2
-
7/23/2019 tugas_method2
1/1
Write a pseudocode application use the method for the tasks below
1. (Parking Charges) A parking garage charges a $2.00 minimum fee to park for up to three hours.
The garage charges an additional $0.50 per hour for each hour or part thereof in ecess of three
hours. The maimum charge for an! gi"en 2#hour period is $10.00. Assume that no car parks
for longer than 2# hours at a time. %rite a pseudocode application that calculates and displa!s
the parking charges for each customer &ho parked in the garage !esterda!. 'ou should enter the
hours parked for each ercises customer. The pseudocode should displa! the charge for the
current customer and should calculate and displa! the running total of !esterda!s receipts. *t
should use the method calculateCharges (!ou must make the method calculateCharges) to
determine the charge for each customer.
2. (ponentiation) %rite a method integerPo&er(+ase, eponent) that returns the "alue of +ase
eponent -or eample, integerPo&er(, #) calculates # (or / / / ). Assume that eponent
is a positi"e, nonero integer and that +ase is an integer. se a for or &hile statement to control
the calculation. *ncorporate this method into an application that reads integer "alues for +ase and
eponent and performs the calculation &ith the integerPo&er method.
. (Temperature Con"ersions) *mplement the follo&ing integer methods
*. 3ethod celsius returns the Celsius e4ui"alent of a -ahrenheit temperature, using the
calculation celsius 5.0 6 7.0 / ( fahrenheit 2 )8
**. 3ethod fahrenheit returns the -ahrenheit e4ui"alent of a Celsius temperature, using thecalculation fahrenheit 7.0 6 5.0 / celsius 9 28
***. se the methods from parts (a) and (+) to &rite a pseudocode application that ena+les the
user either to enter a -ahrenheit temperature and displa! the Celsius e4ui"alent or to enter a
Celsius temperature and displa! the -ahrenheit e4ui"alent.
#. (:e"ersing ;igits) %rite a method that takes an integer "alue and returns the num+er &ith its
digits re"ersed. -or eample, gi"en the num+er