1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
|
/* // A-1-1-01
Author: Ima Coder // A-1-1-02
Date Written: December 11, 2011 // A-1-1-02
Course: CSIS 123, Internet // A-1-1-02
Program: Task 09-02, Chapter 6 // A-1-1-02
Program Description: This application calculates and displays the parking charges // A-1-1-02
for each customer who parked in the garage on a given day. // A-1-1-02
The garage charges a $2.00 minimum fee to park for up to three // A-1-1-02
hours, and an additional $0.50 per hour for each hour or // A-1-1-02
part thereof in excess of three hours. // A-1-1-02
The maximum charge for any given 24-hour period is $10.00. // A-1-1-02
Assume that no car parks for longer than 24 hours at a time. // A-1-1-02
Compiler Used: Microsoft Visual C++ 2010 Express // A-1-1-02
SourceFile Name: Garage.cpp // A-1-1-02
*/ // A-1-1-03
#include <iostream> // A-1-1-04
#include <iomanip> // A-1-1-05
#include <string> // A-1-1-06
#include <cmath> // A-1-1-07
#include <cstdlib> // A-1-1-08
using namespace std; // A-1-1-09
class Garage { // A-1-1-10
public: // A-1-1-11
void prepareDailyReceiptsReport() { // A-1-1-12
int hoursParkedByCustomer[c_customerCount]; // A-1-3-001 TODO
int customerNumber; // A-1-3-002
double totalParkingReceipts = 0; // A-1-3-003 TODO
double parkingCharge; // A-1-3-004 TODO
bool usedMaximumParkingCharge = false; // A-1-3-005 TODO
bool usedMinimumParkingCharge = false; // A-1-3-006 TODO
getDailyParkingActivity(hoursParkedByCustomer); // A-1-3-007 TODO
cout << "\n\nToday's Parking Receipts:\n"; // A-1-3-008
displayColumnHeadings(); // A-1-3-009
for (customerNumber=1;customerNumber<=getCustomerCount();customerNumber++) { // A-1-3-010
parkingCharge = // A-1-3-011 TODO
calculateCustomerParkingCharge // A-1-3-012 TODO
(hoursParkedByCustomer[customerNumber - 1], // A-1-3-013 TODO
usedMaximumParkingCharge, // A-1-3-014 TODO
usedMinimumParkingCharge); // A-1-3-015 TODO
totalParkingReceipts += parkingCharge; // A-1-3-016 TODO
displayThisCustomer // A-1-3-017 TODO
(customerNumber, // A-1-3-018 TODO
hoursParkedByCustomer[customerNumber-1], // A-1-3-019 TODO
parkingCharge, // A-1-3-020 TODO
usedMaximumParkingCharge, // A-1-3-021 TODO
usedMinimumParkingCharge); // A-1-3-022 TODO
} // for // A-1-3-023
displayReportSummaryLine(totalParkingReceipts, "Total Receipts"); // A-1-3-024 TODO
displayReportSummaryLine // A-1-3-025 TODO
(totalParkingReceipts/getCustomerCount(), "Average Fee"); // A-1-3-026 TODO
} // function prepareDailyReceiptsReport // A-1-1-13
private: // A-1-1-14
const static int c_customerColumnWidth = 8; // A-1-1-15
const static int c_customerCount = 30; // A-1-1-16
const static int c_defaultChargeColumnWidth = 7; // A-1-1-17
const static int c_interColumnWidth = 3; // A-1-1-18
const static int c_hoursParkedColumnWidth = 6; // A-1-1-19
const static int c_parkingChargeColumnWidth = 7; // A-1-1-20
double calculateCustomerParkingCharge // A-1-1-21 TODO
( double hoursParked, // A-1-1-22 TODO
bool &usedMaximumParkingCharge, // A-1-1-23 TODO
bool &usedMinimumParkingCharge){ // A-1-1-24 TODO
const double c_minimumParkingCharge = 2.0; // A-1-3-027 TODO
const double c_maximumParkingCharge = 10.0; // A-1-3-028 TODO
const double c_maximumParkingHoursForMinimumParkingCharge = 3.0; // A-1-3-029 TODO
const double c_chargePerHourAfterMinimum = 0.5; // A-1-3-030 TODO
double parkingCharge = c_minimumParkingCharge; // A-1-3-031 TODO
if (hoursParked > c_minimumParkingCharge) // A-1-3-032 TODO
parkingCharge = // A-1-3-033 TODO
c_minimumParkingCharge + c_chargePerHourAfterMinimum // A-1-3-034 TODO
* ceil(hoursParked // A-1-3-035 TODO
- c_maximumParkingHoursForMinimumParkingCharge); // A-1-3-036 TODO
| |