Exercises

  1. 6.7 What is the value of x after each of the following statements is executed?

    1. double x = Math.abs(7.5);

    2. double x = Math.floor(7.5);

    3. double x = Math.abs(0.0);

    4. double x = Math.ceil(0.0);

    5. double x = Math.abs(-6.4);

    6. double x = Math.ceil(-6.4);

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

  2. 6.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 ...

Get Java How to Program, Early Objects, 11th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.