In thisworkshop you are going to use a C structuretype to re

In thisworkshop, you are going to use a C structuretype to represent anItemof an inventory. Apersonis able to viewthe inventory, add an item to the inventory, and check prices for items in the inventory. Here is the C structure type that should be used in this workshop:

structItem{

intsku_;

floatprice_;

intquantity_;

};

sku_: Stock Keeping Unit number for an item.

price_: Price for an item.

quantity_: Quantity of an item.

Also, use constor #define directivesto define the following number:

MAX_ITEMS: the maximum number of items that exists in an inventory. Assume MAX_ITEMSis 10.

In your main function, implement the following steps:

1. Define the following variables in your main program:

structItem item[MAX_ITEMS]; //An array of Item representing the inventory

intsize=0; //Number of items in the inventory. The inventory is initially empty.

2. Display awelcome massage:

Welcome to the Shop

===================

3. Display the following menu, and prompt the user to select anoption from the menu.

Please select from the following options:

1) Display the inventory.

2) Add to the inventory.

0)Exit.

4.You must verify that the input integer is between zero and two inclusive.If the input number is not between zero and two, you must display a warning and prompt the user again. You can assume the user will only enter numbers.The program only exits when the user selects 0 (Exit) on the menu screen (looping required).

5. Depending on the user’s input, one of the following scenarios happens.

Add to the inventory:

Prompt the user to input the SKU number and the quantity of an item that one wants to add to the inventory.

Search through the inventory (the item array) to find if the item exists in the array.

If the item is found in the inventory, do the following:

Update the quantity of the item by adding the quantity read to the quantity of the item in array.

Display a message that the item quantity is successfully updated.

If the item is not found in the inventory, do the following:

If the inventory is full (size== MAX_ITEMS), display the inventory is full.

If the inventory is not full, the function prompts the user to input item price. Then, update the inventory. Hint: Use the inventory array, and size as its index, and assign sku, price and quantity. Increment size.

Display the inventory:

Display the inventory in an informative format. See sample output.

Exit:

Display a goodbye message:

Goodbye!

        

Your program is complete if your output matches the following output. Red numbers show the user’s input.

Welcome to the Shop

===================

Please select from the following options:

1) Display the inventory.

2) Add to shop.

0) Exit.

Select:8

Invalid input, try again: Please select from the following options:

1) Display the inventory.

2) Add to shop.

0) Exit.

Select:2

Please input a SKU number:2341

Quantity:3

Price:12.78

The item is successfully added to the inventory.

Please select from the following options:

1) Display the inventory.

2) Add to shop.

0) Exit.

Select:2

Please input a SKU number:4567

Quantity:9

Price:98.2

The item is successfully added to the inventory.

Please select from the following options:

1) Display the inventory.

2) Add to shop.

0) Exit.

Select:1

Inventory

=========================================

Sku         Price       Quanity

2341        12.78       3

4567        98.20       9

=========================================

Please select from the following options:

1) Display the inventory.

2) Add to shop.

0) Exit.

Select:2

Please input a SKU number:2341

Quantity:5

The item exists in the repository, quanity is updated.

Please select from the following options:

1) Display the inventory.

2) Add to shop.

0) Exit.

Select:1

Inventory

=========================================

Sku         Price       Quanity

2341        12.78       8

4567        98.20       9

=========================================

Please select from the following options:

1) Display the inventory.

2) Add to shop.

0) Exit.

Select:0

Good bye!

In thisworkshop, you are going to use a C structuretype to represent anItemof an inventory. Apersonis able to viewthe inventory, add an item to the inventory, and check prices for items in the inventory. Here is the C structure type that should be used in this workshop:

structItem{

intsku_;

floatprice_;

intquantity_;

};

sku_: Stock Keeping Unit number for an item.

price_: Price for an item.

quantity_: Quantity of an item.

Also, use constor #define directivesto define the following number:

MAX_ITEMS: the maximum number of items that exists in an inventory. Assume MAX_ITEMSis 10.

In your main function, implement the following steps:

1. Define the following variables in your main program:

structItem item[MAX_ITEMS]; //An array of Item representing the inventory

intsize=0; //Number of items in the inventory. The inventory is initially empty.

2. Display awelcome massage:

Welcome to the Shop

===================

3. Display the following menu, and prompt the user to select anoption from the menu.

Please select from the following options:

1) Display the inventory.

2) Add to the inventory.

0)Exit.

4.You must verify that the input integer is between zero and two inclusive.If the input number is not between zero and two, you must display a warning and prompt the user again. You can assume the user will only enter numbers.The program only exits when the user selects 0 (Exit) on the menu screen (looping required).

5. Depending on the user’s input, one of the following scenarios happens.

Add to the inventory:

Prompt the user to input the SKU number and the quantity of an item that one wants to add to the inventory.

Search through the inventory (the item array) to find if the item exists in the array.

If the item is found in the inventory, do the following:

Update the quantity of the item by adding the quantity read to the quantity of the item in array.

Display a message that the item quantity is successfully updated.

If the item is not found in the inventory, do the following:

If the inventory is full (size== MAX_ITEMS), display the inventory is full.

If the inventory is not full, the function prompts the user to input item price. Then, update the inventory. Hint: Use the inventory array, and size as its index, and assign sku, price and quantity. Increment size.

Display the inventory:

Display the inventory in an informative format. See sample output.

Exit:

Display a goodbye message:

Goodbye!

        

Your program is complete if your output matches the following output. Red numbers show the user’s input.

Welcome to the Shop

===================

Please select from the following options:

1) Display the inventory.

2) Add to shop.

0) Exit.

Select:8

Invalid input, try again: Please select from the following options:

1) Display the inventory.

2) Add to shop.

0) Exit.

Select:2

Please input a SKU number:2341

Quantity:3

Price:12.78

The item is successfully added to the inventory.

Please select from the following options:

1) Display the inventory.

2) Add to shop.

0) Exit.

Select:2

Please input a SKU number:4567

Quantity:9

Price:98.2

The item is successfully added to the inventory.

Please select from the following options:

1) Display the inventory.

2) Add to shop.

0) Exit.

Select:1

Inventory

=========================================

Sku         Price       Quanity

2341        12.78       3

4567        98.20       9

=========================================

Please select from the following options:

1) Display the inventory.

2) Add to shop.

0) Exit.

Select:2

Please input a SKU number:2341

Quantity:5

The item exists in the repository, quanity is updated.

Please select from the following options:

1) Display the inventory.

2) Add to shop.

0) Exit.

Select:1

Inventory

=========================================

Sku         Price       Quanity

2341        12.78       8

4567        98.20       9

=========================================

Please select from the following options:

1) Display the inventory.

2) Add to shop.

0) Exit.

Select:0

Good bye!

Solution

struct Item{

int sku_;

float price_;

int quantity_;

};

structItem item[10];

int size=0,n,i;

printf(\"Welcome to the shop\ \");

int i=0;

char choice,option;

char choice0=Exit;

char choice1=Display the inventory;

char choice2=Add to shop;

printf(\"-------------------------------------------------------------------------------------------------------\ \");

printf(\"-------------------------------------------------------------------------------------------------------\ \");

printf(\"sku | Price | Quantity\ \");

printf(\"-------------------------------------------------------------------------------------------------------\ \");

printf(\"--------------------------------------------------------------------------------------------------------\ \");

  

In thisworkshop, you are going to use a C structuretype to represent anItemof an inventory. Apersonis able to viewthe inventory, add an item to the inventory, a
In thisworkshop, you are going to use a C structuretype to represent anItemof an inventory. Apersonis able to viewthe inventory, add an item to the inventory, a
In thisworkshop, you are going to use a C structuretype to represent anItemof an inventory. Apersonis able to viewthe inventory, add an item to the inventory, a
In thisworkshop, you are going to use a C structuretype to represent anItemof an inventory. Apersonis able to viewthe inventory, add an item to the inventory, a
In thisworkshop, you are going to use a C structuretype to represent anItemof an inventory. Apersonis able to viewthe inventory, add an item to the inventory, a
In thisworkshop, you are going to use a C structuretype to represent anItemof an inventory. Apersonis able to viewthe inventory, add an item to the inventory, a
In thisworkshop, you are going to use a C structuretype to represent anItemof an inventory. Apersonis able to viewthe inventory, add an item to the inventory, a

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site