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

C++ code only! Objective: In this assignment, you will familiarize with C++ prim

ID: 3798310 • Letter: C

Question

C++ code only!

Objective: In this assignment, you will familiarize with C++ primitive types, raw arrays, and functions. Additionally, you will have to analyze the runtime of your design. You are provided with the signatures for multiple functions. Your task is to complete the functions and solve the appropriate task

Required: bool neighborhoodIsViable (…) This function should take in the customer data and return true if you will break even or profit, or return false if there will be a loss. All input values are positive numbers (aside from chosenCust data). If you will return true, values should be set in chosenCust representing a set of customers making this true.

numCust: number of customers

maxBandwidth: maximum amount of bandwidth you can support (positive number) ***When selecting customers, the total bandwidth requested by the customers should be less than or equal to this maximum***.

#include
using namespace std;

bool neighborhoodIsViable(const int& numCust,
const int& maxBandwidth,
const int& maintenanceCost,
const int* const reqBand,
const int* const reqPrice,
bool* const chosenCust) {

return false;
}

int main() {
//////////////////////////////////////////////
// Change these values to get a new test case.
int numCust = 5;
int maxBandwidth = 150;
int maintenanceCost = 100;
int reqBand[] = {30, 40, 150, 20, 60};
int reqPrice[] = {40, 60, 100, 20, 70};
bool chosenCust[5];
double partialCust[5];
//////////////////////////////////////////////

// Check if neighboorhood is viable.
bool isViable = neighborhoodIsViable(numCust, maxBandwidth, maintenanceCost, reqBand, reqPrice, chosenCust);

int bandwidthUsed = 0;
int moneyCharged = 0;

if(isViable) {
cout << "Viable venture. A set of customers that works: " << endl;
cout << "{" << chosenCust[0];
for(int i=1; i cout << ", " << chosenCust[i];
}
cout << "}" << endl;
  
for(int i=0; i if(chosenCust[i]) {
bandwidthUsed += reqBand[i];
moneyCharged += reqPrice[i];
}
}
cout << "Bandwidth used by customers: " << bandwidthUsed << ", money paid by customers: " << moneyCharged << endl;
}
else {
cout << "Not viable." << endl;
}

maintenanceCost: cost to run network in this neighborhood (positive number) u You are looking to see if you have customers you can support within your bandwidth limit who will pay greater than or equal to your maintenance cost. reqBand: array of size numCust. o reqBand is the bandwidth customer i wants (positive number). reqPrice: array of size numCust. o reqPrice[i] is the price customer i wants (positive number). chosen Cust: array of size numCust. o The values selected to be true in chosenCust should give a total amount of bandwidth less than or equal to max bandwidth. The values selected to be true in chosenCust should give a total amount ofprice that is greater than or equal to maintenance costs (you do not need to provide the best subset, simply a subset that profits/breaks even). Return value. return true if some subset of customers can allow you to break even or make a profit. o Update the values in chosencust to reflect a subset of customers to offer service. For example, if you chose to offer Customer 0 to have service, Customer 1 to have service, and Customer 2 to have no service, then the values would be chosen Cust[0] true chosen Cust[1] true chosen Cust[2] false return false if no subset of customers can make a profit.

Explanation / Answer

#include<iostream.h>
#include<conio.h>
using namespace std;
bool neighborhoodIsViable(const int& numCust,
const int& maxBandwidth,
const int& maintenanceCost,
const int* const reqBand,
const int* const reqPrice,
bool* const chosenCust) {
return false;
}
int main() {
//////////////////////////////////////////////
// Change these values to get a new test case.
int numCust = 5;
int maxBandwidth = 150;
int maintenanceCost = 100;
int reqBand[] = {30, 40, 150, 20, 60};
int reqPrice[] = {40, 60, 100, 20, 70};
bool chosenCust[5];
double partialCust[5];
//////////////////////////////////////////////

// Check if neighboorhood is viable.
bool isViable = neighborhoodIsViable(numCust, maxBandwidth, maintenanceCost, reqBand, reqPrice, chosenCust);

int bandwidthUsed = 0;
int moneyCharged = 0;

if(isViable) {
cout << "Viable venture. A set of customers that works: " << endl;
cout << "{" << chosenCust[0];
for(int i=1; i< numCust ;i++)
{
cout << ", " << chosenCust[i];
}
cout << "}" << endl;
  
for(int i=0; i < numCust ;i++)
{
if(chosenCust[i]) {
bandwidthUsed += reqBand[i];
moneyCharged += reqPrice[i];
}
}
cout << "Bandwidth used by customers: " << bandwidthUsed << ", money paid by customers: " << moneyCharged << endl;
}
else {
cout << "Not viable.";
}
return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote