Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

//PLEASE HELP ME REMOVE THE ERROR FROM THIS PROGRAM USING C++] #include #include #include #include using namespace std; const int NUM_DEVICES = 10; const int

//PLEASE HELP ME REMOVE THE ERROR FROM THIS PROGRAM USING C++]

#include #include #include #include

using namespace std;

const int NUM_DEVICES = 10; const int price = 12000 ;

struct devicedata { string device_name; float price[price]; char total_price_per_purchase; string devicedata; };

void Program_Description(); void get_devices(); void read_device_data(ifstream&, devicedata[]); void write_device_data(); void read_device_prices(devicedata[]); void calculate_total_expenses(devicedata[]); void disp_table(ofstream&, int, string, double);

int main() { int choice; string deviceName; string fileName; float total_price; ofstream outFile; ifstream inFile; devicedata prices[NUM_DEVICES]; Program_Description();

do { cout << "Option to choose from "<> choice;

if(choice == 1) { cout << "Enter the file name"<> fileName; inFile.open(fileName.c_str()); if(inFile.fail()) { cout<<" error"<> prices[i].deviceName; cout <<"Enter the device price"<> prices[i].price[j]; } } calculate_total_prices(prices); } else if(choice == 3) { sortAscending(prices); } else if(choice == 4) { calculate_total_prices(prices); } else if(choice == 5) { cout<<"Enter the device that you're looking for"<> devicename; int i =0; bool found = false; while ((!found)&&(i<=NUM_DEVICES)) { if(devicename == price[i].devicename) { found = true; } else i++; } cout<< "No Device Price"<

writedeviceData(outFile, prices); outFile.close(); } else if(choice == 7) { displayData(prices); } else if (choice == 8) { cout<<"Finish"<

} else { cout << "Invalid number entered"<= 1) && (choice < 8)); inFile.close();

return 0; }

void get_data(double& electrical, double& electronic) { for(int i = 0; i < 5; i++) { cout << "Enter device code" << i+1 << ":"; cout << "electrical" <> electrical; } for(int i = 0; i < 5; i++) { cout << "Enter device code" << i+1 << ":"; cout << "electronic" <> electronic; cin.ignore(); }

cout << endl << endl; }

void read_device() { getline(fin, device); }

void read_device_prices(double&) { string device; fin>>device; fin>>prices; }

void calculate_total_price() {

int totalexp, qty, price, discount;

cout<<"Enter total quantity:"; cin>>qty; cout<<"Enter total price:"; cin>>price;

totalexp=qty*price;

if(totalexp>5000) { discount=(totalexp*0.1); totalexp=totalexp-discount; }

cout<<"Total Expense is RM. "<

}

void disp_table(ofstream& fout, int loop, string device, double prices) { fout<

//******************************************// //PLEASE HELP ME REMOVE THE ERROR FROM THIS PROGRAM USING C++ // thanks in advance.

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 Design And SQL For DB2

Authors: James Cooper

1st Edition

1583473572, 978-1583473573

More Books

Students also viewed these Databases questions

Question

Illustrate the link between business

Answered: 1 week ago