Write a program in C as follows:- Create an array of integers named “toy” that has 120 rows and 4 columns.- The program should repeatedly display the following menu:A or a to add a toy to the bagV or v to calculate and display the total value of the toysW or w to calculate and display the total weight of the toysD or d to delete a toy from the arrayM or m to calculate and display the number of small toysN or n to calculate and display the number of medium toysL or l to calculate and display the number of large toysX or x to start filling a new bagP or p to exit program               - Santa’s bag can hold 30 large toys or 60 medium toys or 120 small toys or any combination ofsizes that satisfy this requirement (ex: 29 large + 1 medium + 2 small would be max capacity).Also, the total weight of toys cannot exceed 620 Kgs. All values are entered in centimeters andgrams. (Hint: the return values of the size function should help you in calculating the bagcapacity.)The following functions need to be created and used in the program:- Void wipe(int cat[][4], int n);- Void populate(int cat[][4], int n);- Int size(int L, int W, int H);- Int check_capacity(int cat[][4], int n, int tsize, int tweight);- Int rm_toy(int cat[][4], int n, int toynum);- Int weight(int cat[][4], int n);- Int value(int cat[][4], int n);- Int small(int cat[][4], int n);- Int medium(int cat[][4], int n);- Int large(int cat[][4], int n);Functions:- The function wipe that will overwrite the array with zeros.- Populate function asks the user for the bag number, as a two digit number from 10 to 99, andpopulates the first column array with the individual toy numbers as the concatenation of thebag number and the numbers from 1 to 120.(e: if bag number is 12 then the toy numbers wouldbe 12001, 12002, 12003, 12004,..., 12119, 12120)- Size function takes three parameters in cm as the length width and height of a box and return aninteger as follows: 0 if any of the three dimensions is greater than 100 or less than 1 4 if any of the three dimensions is greater than 75 2 if any of the three dimensions is greater than 50 1 if any of the dimensions is greater than 0 an less than or equal 50- Check_capacity function will have four parameters, one of them is the weight of the toy, one ofthem is the value returned by the size function and will return a 0 if the array cannot add thespecific box, and 1 if it can be added (hint: you have to Check how many of each size box arepresent in the array and the total weight of the boxes to make the determination if a 0 or a 1is returned. The functions below can be used inside the check_capacity function as well.).- Rm_toy deletes a toy from the array if the argument passed to the parameter toynum matchesa toy number in the array. The function returns 1 if a match was found and deleted.- The weight function returns the total weight of the toys in the array.- The value function returns the total value of the toys in the array.- The small function returns the total number of small boxes.- The medium function returns the total number of medium boxes.               - The Large function returns the total number of large boxes.Menu options:- Option A: To add a toy to the bag, the user is asked for the length, width, height, and weight ofthe bag. The function size, check_capacity, and weight are called to determine if the box can beadded. If it can be added, then the user is asked for the value in dollars (no cents) and the nextavailable array location(row) will be populated with the size(as returned by the size function),weight, and value.- Option V: call the function value on the array and display the return total value in main.- Option W: call the function weight on the array and display the return total weight in main.- Option D: ask the user for a toy number, use the delete function to attempt toy deletion, outputa message in main stating weather deletion is successful or not.- Options M, N, and L are similar to V and W.- Option X: call function wipe and then ask the user for a bag number and pass as argument tofunction populate. Enter option X first every time you start the program too.- Option P: exit program

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter10: Pointers
Section: Chapter Questions
Problem 5PP
icon
Related questions
Question

Write a program in C as follows:
- Create an array of integers named “toy” that has 120 rows and 4 columns.
- The program should repeatedly display the following menu:
A or a to add a toy to the bag
V or v to calculate and display the total value of the toys
W or w to calculate and display the total weight of the toys
D or d to delete a toy from the array
M or m to calculate and display the number of small toys
N or n to calculate and display the number of medium toys
L or l to calculate and display the number of large toys
X or x to start filling a new bag
P or p to exit program

 
 
 
 
 
 
 
- Santa’s bag can hold 30 large toys or 60 medium toys or 120 small toys or any combination of
sizes that satisfy this requirement (ex: 29 large + 1 medium + 2 small would be max capacity).
Also, the total weight of toys cannot exceed 620 Kgs. All values are entered in centimeters and
grams. (Hint: the return values of the size function should help you in calculating the bag
capacity.)
The following functions need to be created and used in the program:
- Void wipe(int cat[][4], int n);
- Void populate(int cat[][4], int n);
- Int size(int L, int W, int H);
- Int check_capacity(int cat[][4], int n, int tsize, int tweight);
- Int rm_toy(int cat[][4], int n, int toynum);
- Int weight(int cat[][4], int n);
- Int value(int cat[][4], int n);
- Int small(int cat[][4], int n);
- Int medium(int cat[][4], int n);
- Int large(int cat[][4], int n);
Functions:
- The function wipe that will overwrite the array with zeros.
- Populate function asks the user for the bag number, as a two digit number from 10 to 99, and
populates the first column array with the individual toy numbers as the concatenation of the
bag number and the numbers from 1 to 120.(e: if bag number is 12 then the toy numbers would
be 12001, 12002, 12003, 12004,..., 12119, 12120)
- Size function takes three parameters in cm as the length width and height of a box and return an
integer as follows:
 0 if any of the three dimensions is greater than 100 or less than 1
 4 if any of the three dimensions is greater than 75
 2 if any of the three dimensions is greater than 50
 1 if any of the dimensions is greater than 0 an less than or equal 50
- Check_capacity function will have four parameters, one of them is the weight of the toy, one of
them is the value returned by the size function and will return a 0 if the array cannot add the
specific box, and 1 if it can be added (hint: you have to Check how many of each size box are
present in the array and the total weight of the boxes to make the determination if a 0 or a 1
is returned. The functions below can be used inside the check_capacity function as well.).
- Rm_toy deletes a toy from the array if the argument passed to the parameter toynum matches
a toy number in the array. The function returns 1 if a match was found and deleted.
- The weight function returns the total weight of the toys in the array.
- The value function returns the total value of the toys in the array.
- The small function returns the total number of small boxes.
- The medium function returns the total number of medium boxes.
 
 
 
 
 
 
 
- The Large function returns the total number of large boxes.
Menu options:
- Option A: To add a toy to the bag, the user is asked for the length, width, height, and weight of
the bag. The function size, check_capacity, and weight are called to determine if the box can be
added. If it can be added, then the user is asked for the value in dollars (no cents) and the next
available array location(row) will be populated with the size(as returned by the size function),
weight, and value.
- Option V: call the function value on the array and display the return total value in main.
- Option W: call the function weight on the array and display the return total weight in main.
- Option D: ask the user for a toy number, use the delete function to attempt toy deletion, output
a message in main stating weather deletion is successful or not.
- Options M, N, and L are similar to V and W.
- Option X: call function wipe and then ask the user for a bag number and pass as argument to
function populate. Enter option X first every time you start the program too.
- Option P: exit program
AI-Generated Solution
AI-generated content may present inaccurate or offensive content that does not represent bartleby’s views.
steps

Unlock instant AI solutions

Tap the button
to generate a solution

Knowledge Booster
Array
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
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage