can you fix my code in c++? #include #include #define SIZE 3 using namespace std; string readType() { string *type = new string; cout > d_info; } int highestType(string *dt[], int *d_price, int...


can you fix my code in c++?



#include


#include


#define SIZE 3



using namespace std;



string readType() {


  string *type = new string;


  cout < "drone="" type:="">


  getline(cin, *type);


  return type;


}



void readData(string dtype, int *d_info[]) {


  cout <>


  cin >> d_info;


}



int highestType(string *dt[], int *d_price, int *d_qty) {


  float sales; int d_Highest;


  int index;



  d_Highest=*d_price();


  cout<"sales amount="" :=""><>


  for (int i = 0; i < size;="" i++)="">




    sales=(float)*d_price[i] * (*d_qty[i]);


    cout < *dt[i]="">< "="" -="" "=""><>< sales=""><>



    if (sales


      d_Highest = sales;


      index = i;


    }


  }



  cout <>



  return index;


}



//Start main function


int main() {


  string *dtypes [SIZE];


  int *dprice;


  int *dqty [SIZE];



  // Examples of type, sales price and sales quantity of drone


  // DJI Mini2 - RM 2000 - 200 qty


  // DJI Phantom4 - RM 5500 - 400 qty


  // DJI PhantomPro - RM 6150 - 30 qty


  for (int x = 0; x < size;="" x++)="">


    dtypes[x] = readType();



    dprice[x] = new Int;


    readData("Sales price (RM): " , dprice[x]);



    dqty[x] = new Int;


    readData("Sales quantity : " , dqty[x]);



    cin.ignore(); // need this as we mix the use of getline and cin



    cout <>


  }



  int idx1 = highestType(dtypes, dprice, dqty);



  cout < "highest="" amount="" sales="" is="" for="" drone="" type="" "=""><>


< "="" priced="" at="" rm="" "="">< *dprice[idx1]="">< "="" for="">


< dqty[idx1]="">< "="" of="" sales="">



  // delete array data from memory


  for (int x = 0; x < size;="" x++)="">


    delete dtypes[x];


    delete dprice[x];


    delete dqty[x];


  }



  return 0;


}



output


Drone type: DJI Mini2


Sales price (RM): 2000


Sales quantity : 200



Drone type: DJI Phantom4


Sales price (RM): 5500


Sales quantity : 400



Drone type: DJI PhantomPro


Sales price (RM): 6150


Sales quantity : 30



Sales Amount :


DJI Mini2 - RM400000


DJI Phantom4 - RM2.2e+06


DJI PhantomPro - RM184500



Highest amount sales is for drone type DJI Phantom4 priced at RM


5500 for 400 of sales amount

Jun 08, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here