Exercises

  1. 6.11 Show the value of x after each of the following statements is performed:

    1. x = fabs(7.5);

    2. x = floor(7.5);

    3. x = fabs(0.0);

    4. x = ceil(0.0);

    5. x = fabs(-6.4);

    6. x = ceil(-6.4);

    7. x = ceil(-fabs(-8 + floor(-5.5)));

  2. 6.12 (Parking Charges) A parking garage charges a $20.00 minimum fee to park for up to three hours. The garage charges an additional $5.00 per hour for each hour or part thereof in excess of three hours. The maximum charge for any given 24-hour period is $50.00. Assume that no car parks for longer than 24 hours at a time. Write a program that calculates and prints the parking charges for each of three customers who parked their cars in this garage yesterday. You should enter the hours parked for each customer. Your program ...

Get C++ How to Program, 10/e 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.