Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#include #include using namespace std; const int max = 5; //function to read stock info from array //and print output void productInfo(string stockArr[][max], int row,

#include #include using namespace std; const int max = 5;

//function to read stock info from array //and print output void productInfo(string stockArr[][max], int row, int col, int quantity) { //copy user searched product data string data = stockArr[row][col]; //to check index of data string int check = 0; //to store product name string proName; //to store product quantity int qua; //to store product rm float RM; //sstream to split product info stringstream ss(data); //split data by space( ) //by this we will got serach array coordinates //data into values(name, quantity, rm) while (getline(ss, data, ' ')) {

//check if its first word of line or not if (check == 0){ proName = data; check++; } else if (check == 1){ int count = 0; /ow split with colon to get quantity //of product stringstream ss(data); while (getline(ss, data, ':')){ if (count == 1) qua = stoi(data); count++; } check++; } else if (check==2) { int count = 0; /ow split with colon to get RM //of product stringstream ss(data); while (getline(ss, data, ':')){ if (count == 1) RM = stoi(data);//stoin function to convert string into int count++; } check++;

} }

//Output the item name cout

//output the availability of the item quantity if (quantity > qua) cout

//output total price during checkout cout

}

//main driver function int main() { //to store user co-ordinates for product searching int row; int col; //get user quantity int quantity; //store all products in 2D array string StockDataArr[][max] = { { "Maggimee Qty:12 RM:4.50", "Cintanmee Qty:2 RM:3.50", "Sardin Qty:5 RM:4.50", "Mee hoon Qty:20 RM : 4.50", "Kueh teow Qty:1 RM:4.50" }, { "Lemon juice Qty:20 RM:2.50", "Milo Qty:12 RM:11.50", "Horlicks Qty:0 RM:14.50", "Vicco Qty:0 RM:12.50", "Coffee Qty:10 RM:10.50" }, { "Chocolate Qty:10 RM:9.50", "WhiteSugar Qty:18 RM:4.50", "Blacksugar Qty:19 RM:4.50", "Gingerpowder Qty:20 RM:5.50", "Chillipowder Qty:8 RM:6.50" }, { "Crab Qty:12 RM:9.50", "Prawn Qty:5 RM:18.90", "Squid Qty:11 RM:4.50", "Scallop Qty:2 RM:12", "Fishball Qty:16 RM:5.50" }, { "Potato Qty:10 RM:3.50", "Garlic Qty:5 RM:6.50", "Sawi Qty:4 RM:2.80", "Carrot Qty:0 RM:1.50", "Mushroom Qty:12 RM:6.50" } }; //get user inputs cout > row; cout > col; cout > quantity; //calling productInfo function productInfo(StockDataArr, row, col, quantity); cout

}

image text in transcribed

Please convert from c++ to c language program

Below is the stock layout coordinate proposed by Wellwart Supermart. You are requested to design a checkout system for the supermart. Inputs are the column and row coordinate, required quantity. Outputs are the item name, availability stocks, price per unit, and total price during checkout. If the inserted quantity is more than available quantity, massage "not enough stock, please select again the quantity". Coordinate [1] [2] [3] [4] [5] [A] *Maggi mee Cintanmee Sardin Mee hoon Kueh teow Qty:19 Qty:20 Qty:5 Qty:3 Qty:1 RM:4.50 RM:3.50 RM:4.50 RM:4.50 RM:4.50 [B] Lemon juice ** Milo Horlicks Vicco ** Coffee Qty:20 Qty:12 Qty:2 Qty:8 Qty:5 RM:2.50 RM:11.50 RM:14.50 RM:12.50 RM:10.50 [C] Chocolate *White Black sugar Ginger Chilli powder powder Sugar Qty:19 powder Qty:8 Qty:10 Qty:18 RM:4.50 Qty:20 RM:6.50 RM:9.50 RM:4.50 RM:5.50 [D] ** Crab Prawn *Squid Scallop Fishball Qty:12 Qty:0 Qty:11 Qty:2 Qty:16 RM:9.50 RM:18.90 RM:4.50 RM:12 RM:5.50 [E] Potato Garlic Sawi Carrot *Mushroom Qty:10 Qty:5 Qty:4 Qty:1 Qty:12 RM:3.50 RM:6.50 RM:2.80 RM:1.50 RM:6.50 Note: If you are Wellmart supermarket registered member, you will get 10% (*) & 5%(**) discount for selected item

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

Step: 3

blur-text-image

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

Understanding Databases Concepts And Practice

Authors: Suzanne W Dietrich

1st Edition

1119827949, 9781119827948

More Books

Students also viewed these Databases questions

Question

Provide examples of KPIs in Human Capital Management.

Answered: 1 week ago

Question

What are OLAP Cubes?

Answered: 1 week ago