Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

PARKING TICKET SYSTEM Our town\'s police department needs a new program to keep

ID: 3567176 • Letter: P

Question

PARKING TICKET SYSTEM Our town's police department needs a new program to keep track of parking tickets written within their jurisdiction. This system would allow the department to store, search and track parking tickets. Here are the main features of the program; 1) Create a New Parking Ticket [40 points] The police officers use this feature to enter parking tickets they write every day into the system. For each ticket, system asks for the ticket number (a number between 1-20000), the dollar amount on the ticket (currency) and the plate number of the car (it is really a text with no spaces). Each ticket has a status flag associated with it -- either paid or unpaid. Upon entering a ticket into the system, the status of that ticket should be automatically set to unpaid. 2) Pay a Parking Ticket [40 points] Upon payment received, we would like to mark the tickets as paid. The officer enters the ticket number, the program should find the ticket and change its status to paid. 3) Report by Plate Number [SO points] The officer enters a plate number and the program lists all tickets associated with that plate number and displays the total money owed -- sum the amounts on each ticket and display the result as total amount owed. 4) Grand Report [40 points] Displays all the tickets in the program along with their paid/unpaid status. It also reports the number of paid tickets and the number of unpaid are in the system. 5) Exit [5 points] Exits the program. Make sure that your program is presentable, user friendly (25 points). Avoid Penalties: - Each feature must be in a separate function (-50). You must use arrays to hold the data (-50) - Your program does not compile and/or crashes while running (-50). - Your program is not properly indented and commented (-50). Assume that I will deduct the maximum amount if you hit these penalties. I will also deduct the maximum amount if any of the features of the program is not functioning properly.

Explanation / Answer

#include <iostream>
#include <string>
#include <iomanip>
using namespace std;

//Banner for all screens
void banner()
{
   system("CLS");
   cout << "*******************************************************" << endl;
   cout << " Parking Ticket System" << endl;
   cout << "*******************************************************" << endl;
}

//create new parking ticket
void newTicket(int ticketNum[], double amount[],string plateNum[], bool ticketPaid[], int count)
{
   banner();
   int ticketNumberInt = 0, i = 0;
   cout << "Please enter ticket number: ";
   cin >> ticketNumberInt;
   while (ticketNumberInt < 1 || ticketNumberInt > 20000)
   {
   cout << "Wrong input" << endl;
   cout << "Please enter ticket number: ";
   cin >> ticketNumberInt;
   }
   for (i; i < 101; i++)
   if (ticketNumberInt == ticketNum[i])
   {
   cout << "Wrong input" << endl;
   cout << "Please enter ticket number: ";
   cin >> ticketNumberInt;
   }
   ticketNum[count] = ticketNumberInt;
   //for (i; i < 101; i++)
   {
//if (ticketNumberInt == ticketNum[i])
//{
//cout << "Already in the system" << endl;
// cout << "Please enter ticket number: ";
// cin >> ticketNumberInt;
// //i = 0;
// continue;
// }
// else
// {
//   
// }
// }
//   

   cout << "Please enter ticket amount: ";
   cin >> amount[count];
   while(amount[count] < 0)
   {
   cout << "Wrong input" << endl;
   cout << "Please enter ticket amount: ";
   cin >> amount[count];
   }
   cout << "Please enter plate number: ";
   cin >> plateNum[count];
   ticketPaid[count] = false;
}

//pay ticket
void payTicket(int ticketNum[], double amount[],string plateNum[], bool ticketPaid[], int count)
{
   banner();
   int ticNum, payNow;
   cout << "Please enter ticket number to pay: ";
   cin >> ticNum;
   for (int i = 0; i < 101; i++)
   {
   if (ticNum == ticketNum[i])
   {
   cout << "Amount due for ticket #" << ticNum << " Amount due: "<< amount[i] << endl;
   cout << "Would you like to pay now?" << endl;
   cout << "1 - Yes" << endl;
   cout << "2 - No" << endl;
   cout << "What is your selection: ";
   cin >> payNow;
   if (payNow == 1)
   {
   cout << "Ticket has been paid" << endl;
   ticketPaid[i] = true;
   //system("PAUSE");
   }
   else
   break;
   }
   }
}

//search for ticket
void reportTicket(int ticketNum[], double amount[],string plateNum[], bool ticketPaid[], int count)
{
   banner();
   string plateNumString;
   double ticketTotal = 0;
   cout << "Please enter plate number: ";
   cin >> plateNumString;
   cout << "ticket# plate# amount ticket paid" << endl;
   for (int i = 0; i < count; i++)
   {
   if (plateNumString == plateNum[i])
   {
   cout << ticketNum[i] << setw(10) << plateNum[i] << setw(10) << amount[i] << setw(10) << ticketPaid[i] << endl;
   if (ticketPaid[i] == false)
   ticketTotal = ticketTotal + amount[i];
   }
   }
   cout << "Total owed: " << ticketTotal << endl;

}

//report all tickets
void grandReport(int ticketNum[], double amount[],string plateNum[], bool ticketPaid[], int count)
{
   banner();
   double sum = 0;
   int unpaid = 0;
   cout << "Record#" << " " << "ticket#" << " " << "amount" << " " << "plate#" << " " << "ticket paid" << endl;
   for (int i = 0; i < count; i++)
   {
   cout << i + 1 << setw(10) << ticketNum[i] << setw(10) << amount[i] << setw(10) << plateNum[i] << setw(10) << ticketPaid[i] << endl;
   if (ticketPaid[i] == false)
   {
   sum = sum + amount[i];
   unpaid++;
   }
   }
   cout << "Total amount owed: " << sum << endl;
   cout << "Total unpaid tickets: " << unpaid << endl;
   cout << "Total paid tickets: " << count - unpaid << endl;
}

int main ()
{
   int choice, count = 0;
   int ticketNum[100];
   double amount[100];
   string plateNum[100];
   bool ticketPaid[100];

   while(true)
   {
   system("color 13");
   banner();
   cout << "1 - Create new parking ticket" << endl;
   cout << "2 - Pay parking ticket" << endl;
   cout << "3 - Report by plate number" << endl;
   cout << "4 - Grand report" << endl;
   cout << "5 - Exit" << endl;
   cout << "What is your selection: ";
   cin >> choice;

   switch (choice)
   {
   case 1:
   system("CLS");
   newTicket(ticketNum, amount, plateNum, ticketPaid, count);
   count++;
   system("PAUSE");
   continue;
   case 2:
   system("CLS");
   payTicket(ticketNum, amount, plateNum, ticketPaid, count);
   system("PAUSE");
   continue;
   case 3:
   system("CLS");
   reportTicket(ticketNum, amount, plateNum, ticketPaid, count);
   system("PAUSE");
   continue;
   case 4:
   system("CLS");
   grandReport(ticketNum, amount, plateNum, ticketPaid, count);
   system("PAUSE");
   continue;
   case 5:
   cout << "goodbye!" << endl;
   system("PAUSE");
   return 0;
   break;
   default:
   cout << "Wrong input!" << endl;
   system("PAUSE");
   }
   }

   system("PAUSE");
   return 0;
}