Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a simple, but complete C++ program that defines a 2D array to help manage the inventory of a local supermarket. Each row represents a

Write a simple, but complete C++ program that defines a 2D array to help manage the inventory of a local supermarket. Each row represents a commodity. Columns are defined by the figure below. In the table, left three columns are input, right four are output. Remember that the code should be as simple as possible.

Id Price Sale Inventory Sale-In Dollar

The main() function does the following.

1) Read the commodity (row) number from the keyboard with proper prompt.

2) Populate the left most four columns using random number generators.

3) Update the elements of the fourth column and calculate the elements of the fifth column, which should be the product of the second column element and the second column element at the same row.

4) Print out the content of the 2D array before and after the calculation in Step 3).

Note: To use the random number generator, add following code

#include

#include

srand(time(NULL));

var = rand() % scope; // scope is the range starting from 0

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions