Question: This is a C++ program (FinalQ1.cpp) with errors (syntax errors and/ or logical errors, if any). fix all error #include #include #define SIZE 3 using

This is a C++ program (FinalQ1.cpp) with errors (syntax errors and/ or logical errors, if any). fix all error

#include #include #define SIZE 3

using namespace std;

string getType() { string *p_data = new string; cout << "Business type: "; cin >> *p_data; return *p_data; }

void setBusinessData(string caption, int *p_data[]) { cout << caption; cin >> *p_data; }

int highestProfit(string *t[], int *c[], int *s[], float *hpp) { float profit_percent, highest_percent = 100; int idx; cout << "Check profit percent: "; for (int i = 0; i < SIZE; i++) { profit_percent = (float) (*s[i] - *c[i]) / *c[i] * 100; cout << t[i] << " - " << profit_percent << "% "; if (highest_percent < profit_percent) { profit_percent = highest_percent; idx = i; } } *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 < SIZE; i++) { types[i] = getType(); capital[i] = new int; setBusinessData("Capital (RM): " , capital[i]); setBusinessData("Sale (RM): " , sale[i]);

cout << " "; } int idx_hp_profit = highestProfit(types, capital, sale, hp_profit); cout << "Most profitable business is " << *types[idx_hp_profit] << " with " << *hp_profit << "% of profit over the capital"; // delete array data from memory for (int i = 0; i < SIZE; i++) { delete types[i]; delete capital[i]; delete sale[i]; } return 0; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!