This system tracks car traffic violation tickets, the data in this system includ
ID: 3771884 • Letter: T
Question
This system tracks car traffic violation tickets, the data in this system include: car plate number, tickcl number, violation type, fine, status (paid or unpaid). The following table shows examples of such records Assume the system will be used by employees in the traffic department When the system runs, the program starts by loading the traffic violoations data from a fixed file. Then the system displays the following menu: Add a new ticket. Delete a ticket (only unpaid tickets can be deleted) Pay a ticket. Display all violation tickets. Search for tickets by car plate no. Display all tickets that are not paid yet. Exit.Explanation / Answer
#include <bits/stdc++h>
using namespace std;
class ticket{
public:
int plate_num;
int tic_num;
string vol_type;
int fine;
string status;
ticket(int p,int t,string v,int f,string s){
plate_num = p;
tic_num = t;
vol_type = v;
fine = f;
status = s;
}
};
int main(){
ifstream infile;
infile.open("input.txt",'r');
vector<ticket*> vect;
while (!infile.eof()){
int p,int t,string v,int f,string s;
infile >> p >> t >> v >> f >> s;
ticket* t = new ticket(p,t,v,f,s);
vect.push_back(t);
}
infile.close();
int n;
while (true){
cout << "1. Add a new Ticket " << endl;
cout << "2. Delete a Ticket (only unpaid tickets can be deleted) " << endl;
cout << "3. pay a ticket " << endl;
cout << "4. Display all violation tickets" << endl;
cout << "5. Search for tickets by car plate number " << endl;
cout << "6. Display all tickets that are not pai yet " << endl;
cout << "7. Exit " << endl;
cout << "Choose an option ";
cin >> n;
if (n == 1){
cout << "Enter plate number, Ticket Number, violation Type, Fine, status : ";
int p,int t,string v,int f,string s;
infile >> p >> t >> v >> f >> s;
ticket* t = new ticket(p,t,v,f,s);
vect.push_back(t);
}
else if (n == 2){
int num;
cout << "Enter the plate number ";
cin >> num;
for (int i = 0; i < vect.size(); i++){
if (vect[i]->plate_num == num){
vect.erase(vect.begin()+i);
break;
}
}
}
else if (n == 3){
int num;
cout << "Enter the plate number ";
cin >> num;
for (int i = 0; i < vect.size(); i++){
if (vect[i]->plate_num == num){
if (vect[i]->status == "unpaid")
vect[i]->status = "paid";
else
cout << "Already Paid" << endl;
break;
}
}
}
else if (n == 4){
for (int i = 0; i < vect.size(); i++){
cout << "Plate Number is " << vect[i]->plate_num << endl;
cout << "Ticket Number is " << vect[i]->tic_num << endl;
cout << "violation Type is " << vect[i]->vol_type << endl;
cout << "Fine is " << vect[i]->fine << endl;
cout << "Status is " << vect[i]->status << endl;
}
}
else if (n == 5){
int num;
cout << "Enter the plate number ";
cin >> num;
for (int i = 0; i < vect.size(); i++){
if (vect[i]->plate_num == num){
cout << "Plate Number is " << vect[i]->plate_num << endl;
cout << "Ticket Number is " << vect[i]->tic_num << endl;
cout << "violation Type is " << vect[i]->vol_type << endl;
cout << "Fine is " << vect[i]->fine << endl;
cout << "Status is " << vect[i]->status << endl;
}
}
}
else if (n == 6){
for (int i = 0; i < vect.size(); i++){
if (vect[i]->status == "unpaid"){
cout << "Plate Number is " << vect[i]->plate_num << endl;
cout << "Ticket Number is " << vect[i]->tic_num << endl;
cout << "violation Type is " << vect[i]->vol_type << endl;
cout << "Fine is " << vect[i]->fine << endl;
cout << "Status is " << vect[i]->status << endl;
}
}
}
else
break;
}
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.