
Write a
- 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
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.
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
to generate a solution
a solution
- In C++: Write a program which will prompt the user to enter an array of 12 characters. The program should then print the array, and then print the array again, but this time as a 4 colums by 3 rows array.arrow_forwardIn C Programming Write a main function that declares an array of 100 ints. Fill the array with random values between 1 and 100. Calculate the average of the values in the array. Output the average.arrow_forwardIn c++, Declare a constant “ SIZE = 5 ” Declare an array of ints , of size SIZE . Initializethat array to have the values 10, 12, 15, 19, 6 .– Write a loop that calculates and prints out the minimum value of the array.– Write a loop that calculates and prints out the maximum value of the array.– Write a loop that calculates and prints out the average value of the array.arrow_forward
- Topic: Array covered in Chapter 7 Do not use any topic not covered in lecture. Write a C++ program to store and process an integer array. The program creates an array (numbers) of integers that can store up to 10 numbers. The program then asks the user to enter up to a maximum of 10 numbers, or enter 999 if there are less than 10 numbers. The program should store the numbers in the array. Then the program goes through the array to display all even (divisible by 2) numbers in the array that are entered by the user. Then the program goes through the array to display all odd (not divisible by 2) numbers in the array that are entered by the user. At the end, the program displays the total sum of all numbers that are entered by the user.arrow_forwardc++ programming Initialize a string array named person with your first, middle andlast name as separate elements. Print the middle name from the array. Iterate to print all values of the array. Output Example WilliamJohn William Henryarrow_forwardGood evening, i am working on this arrays problem and was hoping you could help with it please? (my programming language is c++) Thanks!arrow_forward
- Hello, i need help and i would like explanation too and include pictures of the program too please and thank you!! in c languagearrow_forwardWrite a C++ program that uses a 1D array to store 25 students' computer programming grades (total grade 100). The program should not accept incorrect or invalid grades, and the user should be able to enter marks one at a time. Once the user has completed the entry, the program should output the following. a) Maximum grade b) The average grade (sum of all grades/total number of students) c) Minimum grade Write the C++ code in the space provided (Full marks are awarded for a complete solution.)arrow_forwardProblem Description - JAVA PROGRAMMING Use a Two-dimensional (3x3) array to solve the following problem: Write an application that inputs nine numbers, each of which is between 1 and 10, inclusive. Display the array after the user inputs each value. Rotate/flip the array by changing places. Make the rows columns and vice versa. You have to move the elements to their new locations. Remember to validate the input and display an error message if the user inputs invalid data. Documentation and the screenshot(s) of the results. Example: 1 2 3 4 5 6 7 8 9 the result will be : 1 4 7 2 5 8 3 6 9arrow_forward
- Consider the following program specification: Write a program that will prompt the user for 10 integer values and stores them in an array. The values entered by the user only be between 0 and 100 and the program should validate these appropriately. The program should then: Display the average of the values Display the highest value in the array Display the lowest value in the array Discuss how the values should be validated. What control structures could be used? Using eclipsearrow_forwardIn C write a grading program as follows.- Ask the user for the number of students and store it in an integer variable.- Create an array of floats with four rows and columns equal to the number of students storedearlier.- Initialize the array to zeros.Create a menu with the following options (use a do-while loop and repeatedly display the menu):A or a to add student info one student at a timeT or t to display class average for homeworkS or s to display class average for quizzesB or b to display class average for examsZ or z to exit program (program repeats until this exit command is entered)arrow_forwardWrite 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…arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





