Question

In: Computer Science

***The code is provided below*** When trying to compile the code below, I'm receiving three errors....

***The code is provided below***

When trying to compile the code below, I'm receiving three errors. Can I get some assistance on correcting the issues?

I removed the code because I thought I corrected my problem. I used #define to get rid of the CRT errors, and included an int at main(). The code compiles but still does not run properly. When entering the insertion prompt for the call details, after entering the phone number, the program just continuously runs, instead of prompting next for the date, then time, & language. After the call insertion is complete, the program is suppose to go to Idol state and then route the call to an available agent at the prompt. Program is also suppose to display various statuses such as recently routed calls and stored calls.

Can I get some assistance on correcting the issues so the program runs properly? Also, with cleaner code without using #define?

#define _CRT_SECURE_NO_WARNINGS

#include<iostream>
#include <time.h>
#include <stdlib.h>
#include <ctime>
#include<string.h>

using namespace std;

int i = 0;

struct call
{
    int phno;
    char date[100];
    char time[100];
    int id;
    char lan[100];
    struct call* link;
};

struct call* front = NULL, * rear = NULL;

class Queue
{
public:
    void insert();
    void delcall();
    void status();
};

void Queue::insert()
{
    struct call* p = new call();
    srand(time(NULL));
    time_t curr_time;
    time_t my_time = time(NULL);
    tm* curr_tm;
    time(&curr_time);
    curr_tm = localtime(&curr_time);

    cout << endl << "Inbound Call - Insert to Queue" << endl;
    cout << "Insert Phone Number: ";
        cin >> p->phno;

    strftime(p->date, 50, " %B %d, %Y", curr_tm);

    cout << "Insert Date: ";
        cin >> p->date;

    strcpy_s(p->time, ctime(&my_time));

    cout << "Insert Time: ";
        cin >> p->time;

    cout << "Insert Language: ";
        cin >> p->lan;

    p->id = (rand() % 10 + 1) + i;
    i++;
    p->link = NULL;

    if (rear == NULL)
    {
        front = p;
    }

    else
    {
        rear->link = p;
    }
    rear = p;
}

void Queue::delcall()
{
    if (front == NULL)
    {
        cout << endl << "ACW: No call to route to Agent" << endl;

    }
    else
    {
        cout << endl << "Recently routed call to agent is:" << endl;
        cout << "Phone #: " << front->phno << endl;
        cout << "Date: " << front->date << endl;
        cout << "Call Time: " << front->time;
        cout << "Caller ID: " << front->id << endl;
        cout << "Caller Language : " << front->lan << endl;
        if (front == rear)
        {
            front = rear = NULL;
        }
        else
        {
            front = front->link;
        }
    }
}

void Queue::status()
{
    int j;
    struct call* temp = front;
    if (front == NULL)
        cout << endl << "ACW: No call to route to Agent" << endl;
    else
    {
        cout << endl << "Caller Information" << endl;
        do
        {
            cout << endl << "Stored call details are:" << endl;
            cout << "Phone #: " << temp->phno << endl;
            cout << "Date: " << temp->date << endl;
            cout << "Call Time: " << temp->time;
            cout << "Caller ID: " << temp->id << endl;
            cout << "Caller Language: " << temp->lan << endl;
            temp = temp->link;
            cout << endl;
        } while (temp != NULL);
    }
}

int main()
{
    cout << "          Demo Automatic Call Distributor (ACD) ";
    cout << endl << "-----------------------------------------------------------" << endl;
    cout << endl << "ACW (Average Call Waiting/System Idol)" << endl;
    cout << endl << "New call enters the Queue";
    cout << endl << "Call leaves the Queue and routed to Agent";
  
    int p;
    char ch;
    Queue ob;
    do
    {
        p = (rand() % 3 + 1);
        switch (p)
        {
        case 1:
            ob.insert();
            break;

        case 2:
            ob.delcall();
            break;

        case 3:
            ob.status();
            break;

        }
        cout << endl << "ACW/System Idol" << endl;          
        cout << "waiting...[y/Y]: ";
        cin >> ch;
    } while (ch == 'y' || ch == 'Y');

}

Solutions

Expert Solution

#define _CRT_SECURE_NO_WARNINGS

#include<iostream>
#include <time.h>
#include <stdlib.h>
#include <ctime>
#include<cstring>

using namespace std;

int i = 0;

struct call
{
int phno;
char date[100];
char time[100];
int id;
char lan[100];
struct call* link;
};

struct call* front = NULL, * rear = NULL;

class Queue
{
public:
void insert();
void delcall();
void status();
};

void Queue::insert()
{
struct call* p = new call();
srand(time(NULL));
time_t curr_time;
time_t my_time = time(NULL);
tm* curr_tm;
time(&curr_time);
curr_tm = localtime(&curr_time);
   string flag;//modified
cout << endl << "Inbound Call - Insert to Queue" << endl;
cout << "Insert Phone Number: ";
cin >> p->phno;

strftime(p->date, 50, " %B %d, %Y", curr_tm);

cout << "Insert Date: ";
cin >> p->date;

strcpy(p->time, ctime(&my_time));//error in this line

cout << "Insert Time: ";
cin >> p->time;

cout << "Insert Language: ";
cin >> p->lan;
   getline(cin,flag);//modified
p->id = (rand() % 10 + 1) + i;
i++;
p->link = NULL;

if (rear == NULL)
{
front = p;
}

else
{
rear->link = p;
}
rear = p;
}

void Queue::delcall()
{
if (front == NULL)
{
cout << endl << "ACW: No call to route to Agent" << endl;

}
else
{
cout << endl << "Recently routed call to agent is:" << endl;
cout << "Phone #: " << front->phno << endl;
cout << "Date: " << front->date << endl;
cout << "Call Time: " << front->time;
cout << "Caller ID: " << front->id << endl;
cout << "Caller Language : " << front->lan << endl;
if (front == rear)
{
front = rear = NULL;
}
else
{
front = front->link;
}
}
}

void Queue::status()
{
int j;
struct call* temp = front;
if (front == NULL)
cout << endl << "ACW: No call to route to Agent" << endl;
else
{
cout << endl << "Caller Information" << endl;
do
{
cout << endl << "Stored call details are:" << endl;
cout << "Phone #: " << temp->phno << endl;
cout << "Date: " << temp->date << endl;
cout << "Call Time: " << temp->time;
cout << "Caller ID: " << temp->id << endl;
cout << "Caller Language: " << temp->lan << endl;
temp = temp->link;
cout << endl;
} while (temp != NULL);
}
}

int main()
{
cout << " Demo Automatic Call Distributor (ACD) ";
cout << endl << "-----------------------------------------------------------" << endl;
cout << endl << "ACW (Average Call Waiting/System Idol)" << endl;
cout << endl << "New call enters the Queue";
cout << endl << "Call leaves the Queue and routed to Agent";
  
int p;
string ch;//modified
Queue ob;
do
{
p = (rand() % 3 + 1);
switch (p)
{
case 1:
ob.insert();
break;

case 2:
ob.delcall();
break;

case 3:
ob.status();
break;

}
cout << endl << "ACW/System Idol" << endl;
cout << "waiting...[y/Y]: ";
getline(cin,ch);//modified
} while (ch == "y" || ch == "Y");//modified

}

output:

Demo Automatic Call Distributor (ACD)
-----------------------------------------------------------

ACW (Average Call Waiting/System Idol)

New call enters the Queue
Call leaves the Queue and routed to Agent
ACW: No call to route to Agent

ACW/System Idol
waiting...[y/Y]: y

ACW: No call to route to Agent

ACW/System Idol
waiting...[y/Y]: y

ACW: No call to route to Agent

ACW/System Idol
waiting...[y/Y]: y

ACW: No call to route to Agent

ACW/System Idol
waiting...[y/Y]: y

ACW: No call to route to Agent

ACW/System Idol
waiting...[y/Y]: y

ACW: No call to route to Agent

ACW/System Idol
waiting...[y/Y]: y

Inbound Call - Insert to Queue
Insert Phone Number: 123456789
Insert Date: 12/11/1994
Insert Time: 22-34
Insert Language: english

ACW/System Idol
waiting...[y/Y]: y

Inbound Call - Insert to Queue
Insert Phone Number: 987654321
Insert Date: 9-9-1993
Insert Time: 13-24
Insert Language: chinese

ACW/System Idol
waiting...[y/Y]:n


Related Solutions

Hi, I'm trying to rewrite the code below (code #1) by changing delay() to millis(). void...
Hi, I'm trying to rewrite the code below (code #1) by changing delay() to millis(). void loop() { // Print the value inside of myBPM. Serial.begin(9600); int myBPM = pulseSensor.getBeatsPerMinute(); // Calls function on our pulseSensor object that returns BPM as an "int". // "myBPM" hold this BPM value now. if (pulseSensor.sawStartOfBeat()) { // Constantly test to see if "a beat happened". Serial.println("♥ A HeartBeat Happened ! "); // If test is "true", print a message "a heartbeat happened". Serial.print("BPM:...
Invalid entry code in python my code is pasted below. The last elif statement, I'm trying...
Invalid entry code in python my code is pasted below. The last elif statement, I'm trying to get the program to print "invalid entry" if the entry for user_input is invalid. The first user prompt should only allow for numbers 1-10 and "exit" and "quit" import math user_prompt = """Enter number of operation that you want to execute <type exit or quit to end program>: 1 sin(x) 2 cos(x) 3 tan(x) 4 asin(x) 5 acos(x) 6 atan(x) 7 ln(x) 8...
I'm getting an error for this code? it won't compile import java.util.*; import java.io.*; public class...
I'm getting an error for this code? it won't compile import java.util.*; import java.io.*; public class Qup3 implements xxxxxlist {// implements interface    // xxxxxlnk class variables    // head is a pointer to beginning of rlinked list    private node head;    // no. of elements in the list    // private int count; // xxxxxlnk class constructor    Qup3() {        head = null;        count = 0;    } // end Dersop3 class constructor   ...
The source code I have is what i'm trying to fix for the assignment at the...
The source code I have is what i'm trying to fix for the assignment at the bottom. Source Code: #include <iostream> #include <cstdlib> #include <ctime> #include <iomanip> using namespace std; const int NUM_ROWS = 10; const int NUM_COLS = 10; // Setting values in a 10 by 10 array of random integers (1 - 100) // Pre: twoDArray has been declared with row and column size of NUM_COLS // Must have constant integer NUM_COLS declared // rowSize must be less...
My code does not compile, I am using vim on terminal and got several compiling errors...
My code does not compile, I am using vim on terminal and got several compiling errors this is C++ language I need help fixing my code below is the example expected run and my code. Example run (User inputs are highlighted): Enter your monthly salary: 5000 Enter number of months you worked in the past year: 10 Enter the cost of the car: 36000 Enter number of cars you’ve sold in the past year: 30 Enter number of misconducts observed...
I am creating SAS code, but am receiving an errors " ERROR: Value is out of...
I am creating SAS code, but am receiving an errors " ERROR: Value is out of range or inappropriate. ERROR: No body file. HTML5(WEB) output will not be created." This is the code: option ls=65 ps=65; data one; input IQ; cards; 145 139 122 ; title 'Normal Quantile - Quantile Plot for IQ'; ods graphics on; proc univariate data=one; qqplot IQ / normal (mu=est sigma=est); run;
Question -Please rephrase the passage below . i'm trying to elimate plagrism I'm part of an...
Question -Please rephrase the passage below . i'm trying to elimate plagrism I'm part of an energetic entrepreneurial team aspiring to create a difference in the field of Tech platforms. We are currently working on a software platform that aims to integrate range of media dvices like laptops, mobiles, video recorders and other devices. With growing number of devices in our daily life, it's becoming increasingly complex to manage all devices separately. With this advent, we aim to eliminate the...
1.The below code has some errors, correct the errors and post the working code. Scanner console...
1.The below code has some errors, correct the errors and post the working code. Scanner console = new Scanner(System.in); System.out.print("Type your name: "); String name = console.nextString(); name = toUpperCase(); System.out.println(name + " has " + name.Length() + " letters"); Sample Ouptut: Type your name: John JOHN has 4 letters    2. Write a code that it reads the user's first and last name (read in the entire line as a single string), then print the last name   followed by...
The files provided in the code editor to the right contain syntax and/or logic errors. In...
The files provided in the code editor to the right contain syntax and/or logic errors. In each case, determine and fix the problem, remove all syntax and coding errors, and run the program to ensure it works properly. DebugBox.java public class DebugBox { private int width; private int length; private int height; public DebugBox() { length = 1; width = 1; height = 1; } public DebugBox(int width, int length, height) { width = width; length = length; height =...
The files provided in the code editor to the right contain syntax and/or logic errors. In...
The files provided in the code editor to the right contain syntax and/or logic errors. In each case, determine and fix the problem, remove all syntax and coding errors, and run the program to ensure it works properly. Please Fix code and make Copy/Paste avaliable // Application allows user to enter a series of words // and displays them in reverse order import java.util.*; public class DebugEight4 {    public static void main(String[] args)    {       Scanner input = new Scanner(System.in);       int...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT