For some reason the output will not print the any charge. I don't understand why. I know its a stupid little error, but I am a stupid little programmer. :^)
Code:#include <iostream.h> #include <iomanip.h> #include <windows.h> #include <math.h> void input(int &group, double &time); void computation(int &group, double &time, double &charge); void output(int &group, double &time, double &charge); int main() { int group; // type of vehical array double time; // time in lot variable double charge; // charge variable input(group, time); computation(group, time, charge); output(group, time, charge); return 0; } // definition of input function void input(int &group, double &time) { cout << "Please enter the type of vehical to be charged." << endl; do { cout << "(Enter 1 for Car, 2 for Truck, or 3 for Senior Citizen)" << endl; cin >> group; if(group != 1 && group != 2 && group != 3) { cout << "Please enter a correct charge group"; } } while(group != 1 && group != 2 && group != 3); do { cout << "Please enter the length of time stayed." << endl; cin >> time; if(time <= 0) { cout << "Please enter a positive time"; } } while(time <= 0); } // definition of computation function void computation(int &group, double &time, double &charge) { if(group == 1) { if(time > 5) { charge = (time - 5) * .25 + 2; } else if(time > 1) { charge = (time - 1) * .5; } } if(group == 2) { if(time > 6) { charge = (time - 6) * .75 + 4; } else if(time > 2) { charge = time - 2; } } else { charge = 0; } } // definition of output function void output(int &group, double &time, double &charge) { cout << endl << "Parking Lot Bill" << endl; if(group == 1) { cout << "Charge Group: "<< "Car" << endl; } else if(group == 2) { cout << "Charge Group: " << "Truck" << endl; } else if(group == 3) { cout << "Charge Group: " << "Senior Citizen" << endl; } cout << "Time In Lot : " << time << " Hours" << endl; if(charge = 0) { cout << "Total Charge: " << "No Charge" << endl; } if(charge != 0) { cout << "Total Charge: $" << charge << endl; } cout << endl << "Thank You, Have A Nice Day" << endl; }



LinkBack URL
About LinkBacks


