Question: using c++ please //FinalQ1.cpp// #include #include #define SIZE 3 using namespace std; string getType() { string *p_data = new string; cout > *p_data; return *p_data;
using c++ please

//FinalQ1.cpp//
#include
#include
#define SIZE 3
using namespace std;
string getType() {
string *p_data = new string; cout > *p_data;
return *p_data;
}
void setBusinessData(string *caption, int *p_data[]) { cout
cin >> *p_data;
}
int highestProfit(string *t[], int *c[], int *s[], float *hpp) { float profit_percent, highest_percent = 100;
int idx;
cout
profit_percent = (float) (*s[i] - *c[i]) / *c[i] * 100; cout
if (highest_percent
}
}
*hpp = profit_percent; cout
return idx;
}
// Start main function int main() {
string *types [SIZE]; int *capital [SIZE]; int *sale [SIZE];
float *hp_profit = new int; // highest percentage of profit
// Examples of business types, capital & total sale
// Delivery - RM 300 - RM 450
// Hawker - RM 750 - RM 900
// Tailor - RM 500 - RM 550
for (int i = 0; i
capital[i] = new int;
setBusinessData("Capital (RM): " , *capital[i]);
setBusinessData("Sale (RM): " , sale[i]); cout
//OUTPUT//
Business type: Delivery Capital (RM): 300 Sale (RM): 450
Business type: Hawker Capital (RM): 750 Sale (RM): 900
Business type: Tailor Capital (RM): 500 Sale (RM): 550
Check profit percent: Delivery - 50% Hawker - 20% Tailor - 10% Most profitable business is Delivery with 50% of profit over the capital
Question You are given a C-program (Final01.cpp) with errors (syntax errors and/ or logical errors, if any). The program has three (3) user-defined functions as listed in Table 1. Function Name getType setBusinessData Table 1: Description of functions Description The function asks the users to enter business type and then return the entered data as a string pointer-type variable. The returned business type is later assigned as an item of string pointer type array variable named types. The function accepts two arguments. The first argument is the caption text to guide users to enter the capital or the sale of the business. The second argument is either the capital or the sale data represented by an array of integer pointer type variables: capital and sale. The setBusinessData function assigns data entered by the users to the corresponding item of these array variables. The function accepts three arguments that are the types, capital, and sale parallel amay pointer-type variables. It calculates the profit's percent over the capital for cach business type. For example, delivery profit percent was calculated as: (450 - 300) / 300 * 100. The function also returns the index number of array items which representing the highest profit percent of business highest Profit The main function of the program has a series of calls to getType and setBusinessData functions inside a loop control structure. The types, capital, and sale are parallel array pointer type with references to their item's index was made based on variable used to control the loop (loop which used to make a series of call to getType and setBusinessData functions). Some of the output was produced by a call made to highestProfit function. The last part of the output produced after the index number of parallel array items representing the cheapest menu was retumed by the highestProfit function, You are required to debug the errors, compile, and run the program. You are NOT ALLOWED to remove any statements in the program. You are only allowed to update the statements provided in the program and add a new statement(s) if absolutely necessary. The program should produce the output as in Figure 1. Note: The values in bold are input by the user. 2 Question You are given a C-program (Final01.cpp) with errors (syntax errors and/ or logical errors, if any). The program has three (3) user-defined functions as listed in Table 1. Function Name getType setBusinessData Table 1: Description of functions Description The function asks the users to enter business type and then return the entered data as a string pointer-type variable. The returned business type is later assigned as an item of string pointer type array variable named types. The function accepts two arguments. The first argument is the caption text to guide users to enter the capital or the sale of the business. The second argument is either the capital or the sale data represented by an array of integer pointer type variables: capital and sale. The setBusinessData function assigns data entered by the users to the corresponding item of these array variables. The function accepts three arguments that are the types, capital, and sale parallel amay pointer-type variables. It calculates the profit's percent over the capital for cach business type. For example, delivery profit percent was calculated as: (450 - 300) / 300 * 100. The function also returns the index number of array items which representing the highest profit percent of business highest Profit The main function of the program has a series of calls to getType and setBusinessData functions inside a loop control structure. The types, capital, and sale are parallel array pointer type with references to their item's index was made based on variable used to control the loop (loop which used to make a series of call to getType and setBusinessData functions). Some of the output was produced by a call made to highestProfit function. The last part of the output produced after the index number of parallel array items representing the cheapest menu was retumed by the highestProfit function, You are required to debug the errors, compile, and run the program. You are NOT ALLOWED to remove any statements in the program. You are only allowed to update the statements provided in the program and add a new statement(s) if absolutely necessary. The program should produce the output as in Figure 1. Note: The values in bold are input by the user. 2
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
