Question
Debugging Slove within 25min plz #include #include #define SIZE 3 using namespace std; void getSpec(string caption, string *p_data) { cout > p_data; } void getSpec(string
Debugging Slove within 25min plz
#include
using namespace std;
void getSpec(string caption, string *p_data) { cout > p_data; }
void getSpec(string caption, int p_data) { cout > *p_data; }
int fastestModel(string *m[], int *hp, int *w) { float whp_ratio, whp_ratio_lowest = 0; int idx; cout whp_ratio) { whp_ratio = whp_ratio_lowest; idx = i; } } cout
// Start main function int main() { string *models [SIZE]; int *horsepower [SIZE]; int weight [SIZE]; // Examples of car's models, horse power and weight // Almera - 76 hp - 1035 Kg // City - 88 hp - 1110 Kg // Persona - 80 hp - 1210 Kg // Vios - 78 hp - 1112 Kg for (int i = 0; i
cout Question (35 Marks You are given a C++ program (Fina101.cpp) with errors (syntax errors and/ or logical errors, if any). The program has two (2) user-defined functions as listed in Table 1. Function Name getSpec Table 1: Description of functions Description The function accepts two arguments. The first argument is the caption text to guide users to enter a correct type of car's attributes. The second argument is the car's attribute itself which was represented by a parallel array of pointers type for variables: models, horsepower, and weight. The getSpec function assigns data entered by the users to the corresponding item of these array variables with their index is based on variable used to control the loop. The function accepts three arguments that are the models, horsepower, and weight parallel array pointer variables. It calculates the weight/ horsepower ratio of each car's model and then returns the index number of array item which representing the fastest car (car's model which has the lowest weight/ horsepower ratio). fastestModel The main function of the program has a series of calls to getSpec function inside a loop control structure. The models, horsepower, and weight are parallel pointer type arrays 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 getSpec function). Some of the output was produced by a call made to fastestModel function. The last part of the output produced after the index number of parallel array items representing the fastest car was returned by the fastestModel 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 3 4 5 6 7/Finalqi.cpp #include
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started