Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- class vehicle
- {
- public:
- int vid = 0, vtype = 0, vpay = 0;
- char vreturn;
- int show();
- inline int input()
- {
- cout << "\n______Enter Details______\n";
- cout << "Vehicle Id: ";
- cin >> vid;
- cout << " 1.Car/Van/Jeep:\n ";
- cout << "2.Tractor/mini Bus:\n ";
- cout << "3.BUS/Truck/Road Roller:\n ";
- cout << "4.Axie/Heavy Construction Machinery:\n ";
- cout << "5.7 or more Axie:\n ";
- cout << "SELECT VEHICLE TYPE: ";
- cin >> vtype;
- cout << "Return Journey y/n: ";
- cin >> vreturn;
- switch (vtype)
- {
- case 1:
- if (vreturn == 'n')
- vpay = 50;
- else
- vpay = 90;
- break;
- case 2:
- if (vreturn == 'n')
- vpay = 90;
- else
- vpay = 175;
- break;
- case 3:
- if (vreturn == 'n')
- vpay = 150;
- else
- vpay = 290;
- break;
- case 4:
- if (vreturn == 'n')
- vpay = 300;
- else
- vpay = 550;
- break;
- case 5:
- if (vreturn == 'n')
- vpay = 450;
- else
- vpay = 890;
- break;
- default:
- cout << "Wrong Vehicle Type" << endl;
- }
- }
- };
- int vehicle::show()
- {
- cout << "\n______Details______\n";
- cout << "Vehicle Id\t" << vid;
- cout << "\nVehicle Type\t" << vtype;
- cout << "\nReturn Journey\t" << vreturn;
- cout << "\nToll charges\t" << vpay << endl;
- }
- int main()
- {
- static int count = 0, totalpay = 0, type1 = 0, type2 = 0, type3 = 0, type4 = 0, type5 = 0, type1pay = 0, type2pay = 0, type3pay = 0, type4pay = 0, type5pay = 0;
- vehicle v[50];
- while (1)
- {
- int ch;
- cout << "\n1.Data Entry\n2.Show details\n3.Exit\n";
- cout << "Enter your choice: ";
- cin >> ch;
- switch (ch)
- {
- case 1:
- char choice;
- do
- {
- v[count].input();
- count++;
- cout << "\n you want another entry for vehicle y/n: ";
- cin >> choice;
- } while (choice == 'y');
- break;
- case 2:
- for (int i = 0; i < count; i++)
- {
- v[i].show();
- if (v[i].vtype == 1)
- {
- totalpay += v[i].vpay;
- type1++;
- type1pay += v[i].vpay;
- }
- if (v[i].vtype == 2)
- {
- type2++;
- totalpay += v[i].vpay;
- type2pay += v[i].vpay;
- }
- if (v[i].vtype == 3)
- {
- type3++;
- totalpay += v[i].vpay;
- type3pay += v[i].vpay;
- }
- if (v[i].vtype == 4)
- {
- type4++;
- totalpay += v[i].vpay;
- type4pay += v[i].vpay;
- }
- if (v[i].vtype == 5)
- {
- type5++;
- totalpay += v[i].vpay;
- type5pay += v[i].vpay;
- }
- }
- cout << "\nTotal vehicle passed:" << count << endl;
- cout << "Total Toll Collected:" << totalpay << endl;
- cout << "Sr. |\t"
- << "Vehicle Type |\t"
- << "Individual Amount |\t ";
- cout
- << "\n1. |"
- << "Car/Van/Jeep: | " << type1pay << endl;
- cout << "2. |"
- << "Tractor/mini Bus: |" << type2pay << endl;
- cout << "3. |"
- << "BUS/Truck/Road Roller: | " << type3pay << endl;
- cout << "4. |"
- << "Axie/Heavy Construction Machinery:| " << type4pay << endl;
- cout
- << "5. |"
- << "7 or more Axie: | " << type5pay << endl;
- break;
- case 3:
- return 0;
- default:
- cout << "\nInvalid Choice:" << count << endl;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement