I am trying to code a computer scheduling system with c++. I am using an array-based priority queue. This is the idea of the program

Each input transaction will represent a new computer repair order to be scheduled or a “service” command. A new computer repair order will be represented in three parts separated by hyphens: customer ID (variable length), computer model year (4 digits), warranty code (y or n). Each repair order will be scheduled based on priority and the order in which the repair order was received (first-come-first-served). A warranty repair order (i.e., warranty code = ‘y’) is assigned priority 1 (highest). A non-warranty repair for a computer model less than 6 years old is assigned priority 2. A non-warranty repair order for a computer model older than 5 years is assigned a priority 3 (lowest). Each repair order is placed in a priority queue and will be serviced by the next available repair technician. A transaction that contains a “service” command results in a repair order being removed from the priority queue and the customer ID being displayed on the console. A transaction containing the string “end-of-file” will signal the end of the input. Display the number of repair orders remaining in the queue when the “end-of-file” transaction is processed.

this is my code:

```
#include < iostream>
#include < cmath>
using namespace std;
class heapType{
public:
bool empty();
void service();
void pop();
void push(string cus);
int remain();
heapType();
private:
int C1I;
int C2I;
int CI;
int done;
int EOL;
int count;
string heap[10];
int PI;
void swap(int I1, int I2);
};
bool heapType::empty(){
return (count == 0);}
int heapType::remain(){
return count; }
void heapType::swap(int I1, int I2) {
string T = heap[I1];
heap[I1] = heap[I2];
heap[I2] = T;}
void heapType::service(){
if (count == 0) {} else {
string name = heap[0];
int pos1 = heap[0].find('-');
int pos2 = heap[0].find('-', pos1 + 1);
cout << "(output: " << heap[0].substr(pos2 + 1) << ")" << endl;}}
heapType::heapType() {
EOL = 0;
count = 0;
for (int i = 0; i < 10; i++) heap[i] = "0";}
void heapType::push(string cus){
if (count == 10){
cout << "Error: queue is full." << endl;}
else {
count++;
heap[EOL] = cus;
CI = EOL;
EOL++;
done = 0;
while (!done) {
if (CI == 0)
done = 1;
else {
PI = (CI - 1) / 2;
if (heap[PI] <= heap[CI])
done = 1;
else{
swap(PI, CI);
CI = PI;}}}}}
string change(string choice){
string newExpression;
int p1, p2, intYear;
string name, year, priority, warranty;
static int seq = 1;
string sequence;
p1 = choice.find('-');
p2 = choice.find('-', p1 + 1);
name = choice.substr(0, p1);
warranty = choice.substr(p2 + 1);
year = choice.substr(p1 + 1, p2 - p1 - 1);
intYear = atoi(year.c_str());
if (warranty == "y")
priority = "1";
else if (2019 - intYear < 6)
priority = "2";
else
priority = "3";
newExpression = priority + "-" + sequence + "-" + name;
seq++;
return newExpression;}
void heapType::pop() {
if (count == 0)
cout << "Error: queue is empty.\n";
else {
if (count == 1) {
count = 0;
EOL = 0;
heap[0] = "0";} else {
if (count == 2) {
count = 1;
EOL = 1;
heap[0] = heap[1];
heap[1] = "0";} else {
count--;
EOL--;
heap[0] = heap[EOL];
heap[EOL] = "0";
done = 0;
PI = 0;
C1I = 1;
C2I = 2;
while (!done){
if (C2I >= EOL){
if (heap[PI] > heap[C1I]) swap(PI, C1I);
done = 1;}
else{
if((heap[PI] <= heap[C1I]) && (heap[PI] <= heap[C2I]))
done = 1;
else {
if (heap[C1I] < heap[C2I]) {
swap(PI, C1I);
if ((C1I * 2 + 1) >= EOL)
done = 1;
else
PI = C1I;} else {
swap(PI, C2I);
if ((C2I * 2 + 1) >= EOL)
done = 1;
else
PI = C2I;}
C1I = PI * 2 + 1;
C2I = PI * 2 + 2;}}}}}}}
int main(){
heapType iHeap;
string choice, second;
cout << "\nInput transaction(customerid-year-warrantycode)\n";
cout << "Service(service)\n";
cout << "Exit program(end-of-file)\n";
cin >> choice;
while (choice != "end-of-file"){
if (choice == "service"){
iHeap.service();
iHeap.pop();}
else {
second = change(choice);
iHeap.push(second);}
cout << "\nInput transaction(customerid-year-warrantycode)\n";
cout << "Service(service)\n";
cout << "Exit program(end-of-file)\n";
cin >> choice;}
cout << "(output: There are " << iHeap.remain()
<< " remaining repair orders in the queue)";
return 0;}
```

example inputs are:

jim-2001-y

jake-2012-y

frank-2011-y

james-2019-y

when input is service, the output is:

frank

correct output should be:

jim

I was not able to figure what is wrong with my code. If anyone can figure it out please let me know. Greatly appreciated!!