Question

You will write code that mimics a 911 call center where emergency calls are taken and...

You will write code that mimics a 911 call center where emergency calls are taken and routed to the appropriate emergency department. The class to hold information regarding an emergency is called Nine11Call. Information held in this class includes the address of the emergency, the name of the first responding fireman, officer, or other emergency personnel, an int of 0 - 20 representing the level of urgency, and whether or not an ambulance is needed.

Note that all class members are public, so there's no need for setter and getters.

Requirements:

Implement a function called notify911() that will accept a Nine11Call (by reference parameter), and output according to the following chart:

If the urgency is 0 - 10 output:
_personnel_ is responding to _address_.  An ambulance _is/is not_ needed.

11 - 15 output:
_personnel_ is responding to _address_ on an urgent call.  An ambulance _is/is not_ needed.

otherwise output:
Extremely urgent!  Emergency at _address_.  Notify the Mayor!

Where,
_personnel_ is the respondent name,
_address_ is the address of the emergency
_is/is not_ indicates whether or not an ambulance is needed

Make sure the output ends with a newline.

_______________________________________________________________________________________________________

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

class Nine11Call
{
public:
string address; //the street address of the emergency
string respondent; //the name of the first responding officer or emergency personnel
int urgencyLevel; //The higher the level, the more urgent, assume always 0 - 20
bool needAmbulance;

/*
Note that an address must always be provided.
For constructors that exclude other attributes, use the fllowing values, UNLESS OTHERWISE stated.
respondent= "John Blue"
urgencyLevel = 5
needAmbulance = false
*/
  
Nine11Call(string addr); //Only address is provided, use defaults for other attributes
Nine11Call(string addr, bool ambulance); //Address and needAmbulance is provided, use defaults for other attributes EXCEPT
// if ambulance is needed, urgency is set to 15. So if no ambulance needed, urgencyLevel = 5, otherwise 17
Nine11Call(string addr, int howUrgent, bool ambulance); //use the default value for respondent
Nine11Call(string addr, string respondent, int howUrgent ); //needAmbulance set to false
Nine11Call(string addr, string respondent, int howUrgent, bool ambulance ); // All attributes are provided

};

//Implement the constructor(s) and methods here


//Implement the notify911() function here

int main()
{

//The following instantiations MUST work and assign the attributes properly.
//If they do not, you've done something wrong.

Nine11Call cat("123 Maple Grove", "C. Simon", 0, false );
Nine11Call whiteCollar("8 Wall Street" );

//Do not change this array   
Nine11Call calls[6]={ Nine11Call("200 Campus Way", "Ofc. Mary Kelly", 4),
Nine11Call("1782 20th Street", 19, true),
Nine11Call("302 29th Ave", 15, false),
Nine11Call("4 Box Way", 2, true),
Nine11Call("822 Jackson Street", true),
Nine11Call("1602 PA Ave")   

};

//Iterate the calls array and call notify911() for each instance


return 0;

}

Homework Answers

Answer #1

Thanks for the question.


Below is the code you will be needing Let me know if you have any doubts or if you need anything to change.


Thank You !!


===========================================================================

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

class Nine11Call
{
public:
string address; //the street address of the emergency
string respondent; //the name of the first responding officer or emergency personnel
int urgencyLevel; //The higher the level, the more urgent, assume always 0 - 20
bool needAmbulance;

/*
Note that an address must always be provided.
For constructors that exclude other attributes, use the fllowing values, UNLESS OTHERWISE stated.
respondent= "John Blue"
urgencyLevel = 5
needAmbulance = false
*/

Nine11Call(string addr); //Only address is provided, use defaults for other attributes
Nine11Call(string addr, bool ambulance); //Address and needAmbulance is provided, use defaults for other attributes EXCEPT
// if ambulance is needed, urgency is set to 15. So if no ambulance needed, urgencyLevel = 5, otherwise 17
Nine11Call(string addr, int howUrgent, bool ambulance); //use the default value for respondent
Nine11Call(string addr, string respondent, int howUrgent ); //needAmbulance set to false
Nine11Call(string addr, string respondent, int howUrgent, bool ambulance ); // All attributes are provided
}
;

//Implement the constructor(s) and methods here
Nine11Call::Nine11Call(string addr) //Only address is provided, use defaults for other attributes
{
address=addr;
respondent= "John Blue";
urgencyLevel = 5;
needAmbulance = false;

}
Nine11Call::Nine11Call(string addr, bool ambulance) //Address and needAmbulance is provided, use defaults for other attributes EXCEPT
{
address=addr;
respondent= "John Blue";
urgencyLevel = 5;
needAmbulance = ambulance;
}

// if ambulance is needed, urgency is set to 15. So if no ambulance needed, urgencyLevel = 5, otherwise 17
Nine11Call::Nine11Call(string addr, int howUrgent, bool ambulance) //use the default value for respondent
{
address=addr;
respondent= "John Blue";
urgencyLevel = howUrgent;
needAmbulance = ambulance;

}

Nine11Call::Nine11Call(string addr, string respondent, int howUrgent ) //needAmbulance set to false
{
address=addr;
respondent= respondent;
urgencyLevel = howUrgent;
needAmbulance = false;
}

Nine11Call::Nine11Call(string addr, string respondent, int howUrgent, bool ambulance ) // All attributes are provided
{
address=addr;
respondent= respondent;
urgencyLevel = howUrgent;
needAmbulance = ambulance;
  
}

//Implement the notify911() function here

void notify911(const Nine11Call &call){
  
   if(0<=call.urgencyLevel && call.urgencyLevel<-10){
       cout<<call.respondent<<" is responding to "<<call.address<<". An ambulance ";
       if(call.needAmbulance)cout<<" is needed.";
       else cout<<" is not needed.\n";
   }else if(11<=call.urgencyLevel && call.urgencyLevel<=15){
       cout<<call.respondent<<" is responding to "<<call.address<<" on a urgent call. An ambulance ";
       if(call.needAmbulance)cout<<" is needed.";
       else cout<<" is not needed.\n";
   }else{
       cout<<"Extremely urgent! Emergency at "<<call.address<<". Notify the Mayor!"<<endl;
   }
}

int main()
{

//The following instantiations MUST work and assign the attributes properly.
//If they do not, you've done something wrong.

Nine11Call cat("123 Maple Grove", "C. Simon", 0, false );
Nine11Call whiteCollar("8 Wall Street" );

//Do not change this array   
Nine11Call calls[6]={ Nine11Call("200 Campus Way", "Ofc. Mary Kelly", 4),
Nine11Call("1782 20th Street", 19, true),
Nine11Call("302 29th Ave", 15, false),
Nine11Call("4 Box Way", 2, true),
Nine11Call("822 Jackson Street", true),
Nine11Call("1602 PA Ave") };

//Iterate the calls array and call notify911() for each instance
for (int i=0 ;i<6;i++){
   notify911(calls[i]);
}

return 0;

}

====================================================================

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
[Java] I'm not sure how to implement the code. Please check my code at the bottom....
[Java] I'm not sure how to implement the code. Please check my code at the bottom. In this problem you will write several static methods to work with arrays and ArrayLists. Remember that a static method does not work on the instance variables of the class. All the data needed is provided in the parameters. Call the class Util. Notice how the methods are invoked in UtilTester. public static int min(int[] array) gets the minimum value in the array public...
Getting the following errors: Error 1 error C2436: '{ctor}' : member function or nested class in...
Getting the following errors: Error 1 error C2436: '{ctor}' : member function or nested class in constructor initializer list on line 565 Error 2 error C2436: '{ctor}' : member function or nested class in constructor initializer list on line 761 I need this code to COMPILE and RUN, but I cannot get rid of this error. Please Help!! #include #include #include #include using namespace std; enum contactGroupType {// used in extPersonType FAMILY, FRIEND, BUSINESS, UNFILLED }; class addressType { private:...
STRICT DOWNVOTE IF NOT DONE FULLY, WILL REPORT ALSO IF COPY PASTED OR MODIFIED ANSWER Develop...
STRICT DOWNVOTE IF NOT DONE FULLY, WILL REPORT ALSO IF COPY PASTED OR MODIFIED ANSWER Develop a class, using templates, to provide functionality for a set of recursive functions. The functions specified as recursive must be written recursively (not iterativly). The UML class specifications are provided below. A main will be provided. Additionally, a make file will need to be developed and submitted. ● Recursion Set Class The recursion set template class will implement the template functions. recursionSet -length: int...
STRICT DOWNVOTE IF NOT DONE FULLY, WILL REPORT ALSO IF COPY PASTED OR MODIFIED ANSWER Develop...
STRICT DOWNVOTE IF NOT DONE FULLY, WILL REPORT ALSO IF COPY PASTED OR MODIFIED ANSWER Develop a class, using templates, to provide functionality for a set of recursive functions. The functions specified as recursive must be written recursively (not iterativly). The UML class specifications are provided below. A main will be provided. Additionally, a make file will need to be developed and submitted. ● Recursion Set Class The recursion set template class will implement the template functions. recursionSet -length: int...
STRICT DOWNVOTE IF NOT DONE FULLY, WILL REPORT ALSO IF COPY PASTED OR MODIFIED ANSWER Develop...
STRICT DOWNVOTE IF NOT DONE FULLY, WILL REPORT ALSO IF COPY PASTED OR MODIFIED ANSWER Develop a class, using templates, to provide functionality for a set of recursive functions. The functions specified as recursive must be written recursively (not iterativly). The UML class specifications are provided below. A main will be provided. Additionally, a make file will need to be developed and submitted. ● Recursion Set Class The recursion set template class will implement the template functions. recursionSet -length: int...
Using c++ You may #include only: <iostream> <cmath> “functions.h” Write the function void readForceValuesFromStdIn(double* leftTeam, double*...
Using c++ You may #include only: <iostream> <cmath> “functions.h” Write the function void readForceValuesFromStdIn(double* leftTeam, double* rightTeam, unsigned const int noParticipants) that will read the list of forces exerted by each wizard alternating by the team into the correct array of doubles (see example in problem description) Define the function bool validForces(const double* forces, unsigned const int noParticipants) using the provided code. This function will be used to ensure that the forces exerted by each team’s wizard are non-negative The...
IntNode class I am providing the IntNode class you are required to use. Place this class...
IntNode class I am providing the IntNode class you are required to use. Place this class definition within the IntList.h file exactly as is. Make sure you place it above the definition of your IntList class. Notice that you will not code an implementation file for the IntNode class. The IntNode constructor has been defined inline (within the class declaration). Do not write any other functions for the IntNode class. Use as is. struct IntNode { int data; IntNode *next;...
Description: In this assignment, you need to implement a recursive descent parser in C++ for the...
Description: In this assignment, you need to implement a recursive descent parser in C++ for the following CFG: 1. exps --> exp | exp NEWLINE exps 2. exp --> term {addop term} 3. addop --> + | - 4. term --> factor {mulop factor} 5. mulop --> * | / 6. factor --> ( exp ) | INT The 1st production defines exps as an individual expression, or a sequence expressions separated by NEWLINE token. The 2nd production describes an...
c++ Program Description You are going to write a computer program/prototype to process mail packages that...
c++ Program Description You are going to write a computer program/prototype to process mail packages that are sent to different cities. For each destination city, a destination object is set up with the name of the city, the count of packages to the city and the total weight of all the packages. The destination object is updated periodically when new packages are collected. You will maintain a list of destination objects and use commands to process data in the list....
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT