Exercises

D.7 What is the value of x after each of the following statements is executed?

a) x = Math.abs( 7.5 );

b) x = Math.floor( 7.5 );

c) x = Math.abs( 0.0 );

d) x = Math.ceil( 0.0 );

e) x = Math.abs( -6.4 );

f) x = Math.ceil( -6.4 );

g) x = Math.ceil( -Math.abs( -8 + Math.floor( -5.5 ) ) );

D.8 (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 excess of three hours. The maximum charge for any given 24-hour period is $10.00. Assume that no car parks for longer than 24 hours at a time. Write an application that calculates and displays the parking charges for each customer who parked in the garage yesterday. You should ...

Get Android™ How to Program, Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.