Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is the code please debug it #include #include #define SIZE 3 using namespace std; string getType() { string *p_data = new string; cout >

image text in transcribed

image text in transcribed

image text in transcribed

This is the code please debug it

#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 > *p_data; }

int highestProfit(string *t[], int *c[], int *s[], float *hpp) { float profit_percent, highest_percent = 100; int idx; cout

// 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

cout Question [35 Marks You are given a C++ program (FinalQ1.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 array pointer-type variables. It calculates the profit's percent over the capital for each 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. highestProfit 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 returned 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. 1 2 //Finalqi.cpp #include #include #define SIZE 3 4 5 6 using namespace std; 8 string getType() string *p data = new string: cout > *p_data; return 'p_data; 1 void set BusinessData(string .caption, int *p_data()) { cout > *p_data; int highest Profit(string *t11, int *cll, int *sfl, float hpp) float profit percent, highest_percent - 100; int idx; cout

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David M. Kroenke

1st Edition

0130086509, 978-0130086501

More Books

Students also viewed these Databases questions

Question

Distinguish between registered and coupon bonds.

Answered: 1 week ago