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 << dtype;   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 : "<

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

can you fix my code in c++?

 

#include <iostream>

#include <string>

#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 << dtype;

  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 : "<<endl;

  for (int i = 0; i < SIZE; i++) {

   

   

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

    cout << *dt[i] << " - " <<"RM"<< sales << "\n";

     

    if (sales<d_Highest) { 

      d_Highest = sales;

      index = i;

    }

  }

   

  cout << "\n";

   

  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 << "\n";

  }

   

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

   

  cout << "Highest amount sales is for drone type " << *dtypes[idx1] 

     << " priced at RM " << *dprice[idx1] << " for " 

     << dqty[idx1] << " of sales amount\n\n";

      

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

Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Header Files
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education