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 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171
|
//
// Lab 04
// 11-10-10
//
//
#include <iostream>
#include <stdio.h>
using namespace std;
#define firstCarRate 0.00
#define secondCarRate 1.50
#define firstTruckRate 1.00
#define secondTruckRate 2.30
#define firstBusRate 2.00
#define secondBusRate 3.70
/*Prototype Declarations */
// Function Prototypes
void getInfo(char *vehicle, int *hourin, int *minin, int *hourOut, int minOut);
void time(int hourin,int hourOut,int minin,int minOut,int *hourParkTime,
int *minParkTime,int *roundedTotal,int *round);
void rate(char vehicle,int *units,float *firstRate,float *secondRate);
void charge(int roundedTotal,int units,float firstRate,float secondRate,float *totalCharge);
void print(char vehicle,int hourin,int minin,int hourOut,int minOut,
int hourParkTime,int minParkTime,int roundedTotal,float totalCharge);
/*global Definitions */
char vehicle;
int units;
int hourin;
int minin;
int hourOut;
int minOut;
int hourParkTime;
int minParkTime;
int roundedTotal;
int round;
float firstRate;
float secondRate;
float totalCharge;
int main(void)
{
/*statements */
getInfo(&vehicle,&hourin,&minin,&hourOut,&minOut);
time(hourin,hourOut,minin,minOut,&hourParkTime,&minParkTime,
&roundedTotal,&round);
rate(vehicle,&units,&firstRate,&secondRate);
charge(roundedTotal,units,firstRate,secondRate,&totalCharge);
print(vehicle,hourin,minin,hourOut,minOut,hourParkTime,minParkTime,
roundedTotal,totalCharge);
system("pause");
return 0;
}/*main*/
void getInfo(char *vehicle,int *hourin,int *minin,int *hourOut,int *minOut)
{
/*Statement*/
cout<< "Type of vehicle?:";
cin >> *vehicle;
cout<< "\nHour vehicle entered lot:";
cin >> *hourin;
cout<< "\nMinute vehicle entered lot:";
cin >> *minin;
cout << "\nHour vehicle left lot:";
cin >> *hourOut;
cout << "\nMinute vehicle left lot:";
cin >> *minOut;
return;
} /* getInfo */
void time(int hourin,int hourOut,int minin,int minOut,
int *hourParkTime,int *minParkTime,int *roundedTotal,int *round)
{
/*Statements */
if (minOut < minin)
{
minOut = minOut +60;
hourOut = hourOut -1;
*hourParkTime = hourOut - hourin;
*minParkTime = minOut - minin;
}
else
{
*hourParkTime = hourOut - hourin;
*minParkTime = minOut - minin;
}
if (*minParkTime >= 1)
{
*round = *"hourParkTime +1";
*roundedTotal = *round;
}
else
{
*round = *hourParkTime;
*roundedTotal = *round;
}
return;
} /* time */
void rate(char vehicle,int*units,float *firstRate,float *secondRate)
{
/* Local Definitions*/
/* Statements */
switch(vehicle)
{
case 'c':
case 'C': "units = 3";
*firstRate = firstCarRate;
*secondRate = secondCarRate;
break;
case 't':
case 'T': "units = 2";
*firstRate = firstTruckRate;
*secondRate = secondTruckRate;
break;
case 'b':
case 'B': "units = 1";
*firstRate = firstBusRate;
*secondRate = secondBusRate;
break;
default: print("\nYou did not enter a valid letter");
print("\nTry Again!");
} /*switch */
return;
} /*rate */
void charge(int roundedTotal,int units,float firstRate,
float secondRate,float *totalCharge)
{
/*Local Definitions */
/* Statements */
if (roundedTotal <= units)
*totalCharge = roundedTotal *firstRate;
else
*totalCharge = (units * firstRate) = ((roundedTotal - units) * secondRate);
return;
}/*charge*/
|