
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question
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
- 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.
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
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
SAVE
AI-Generated Solution
info
AI-generated content may present inaccurate or offensive content that does not represent bartleby’s views.
Unlock instant AI solutions
Tap the button
to generate a solution
to generate a solution
Click the button to generate
a solution
a solution
Knowledge Booster
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
- Write a C++ (visual studio) program that examines a list of numbers to find the smallest value. The list should include 10,000 random whole numbers that range from -1,000,000 to 1,000,000. The program should display the lowest value in the list and the number of the element that contains that value.And create a pseudocode explaining the steps. (if you would give to someone to create the program) The program must have:Declare an array in the main() function that will hold 10,000 integers. Pass the array to the other functions as necessary. Use a reliable algorithm to produce random integers within a given range. Note: stran()/rand() is NOT a reliable random number algorithm. The function should accept the minimum and maximum values that will be generated and return an integer.Examine the array to find the smallest value. Return the smallest value and the number of the element that contains the smallest value.arrow_forwardProgramming in Carrow_forwardThis is an computer programming question The code should be on C++ language Jason is preparing for an upcoming marathon. Each day of the week, he run a certain number of miles and write them into a notebook. At the end of the week, he would like to know the number of miles run each day, the total miles for a week, and average miles for a week. Write a program to help him analyze their data. Your program must contain a two-dimensional array of four rows and seven columns to store the number of miles run each day. Furthermore, your program must contain at least the following functions: a function to read and store the numbers of miles run each day; a function to find the total miles run and the average number of miles run for each week; and a function to output the results.arrow_forward
- er Programming Write a C++ program that uses a 10 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.) If any data is missing, make an appropriate assumption. C F5 F3 F4 F6 F7 F8 F9 %23 %24 4. 3. 01 6. 061 T Yarrow_forwardWrite a program in C++ that allows a user to enter twelve numbers into an array. The program should then calculate and display the total of the numbers, the average of the numbers, and the lowest and highest values entered.arrow_forwardDisplay Array values Write a program that lets the user enter ten values into an array. Then pass the array, the size of the array, and the number, num to a function called displayArrayValues(). The function should then display all the numbers in the array larger than n. Write a program using C++.arrow_forward
- Programing language is Carrow_forwardIn 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_forwardThis is an computer programming questtion The code shoukd be in C++ language Write a C++ program to calculate the percentage and grade of the 5 students according to the followingrequirements:• 1D array for student ID’s of type int• 1D array for student names of type string• 2D array of size 5 x 5 for subjects (English, Urdu, Mathematics, Physics, Computer)Your program should prompt the user to enter the data and display the output according tofollowing template:arrow_forward
- C++arrow_forwardTopic: 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_forwardIn this lab, you use what you have learned about searching an array to find an exact match to complete a partially prewritten C++ program. The program uses an array that contains valid names for 10 cities in Michigan. You ask the user to enter a city name; your program then searches the array for that city name. If it is not found, the program should print a message that informs the user the city name is not found in the list of valid cities in Michigan. The file provided for this lab includes the input statements and the necessary variable declarations. You need to use a loop to examine all the items in the array and test for a match. You also need to set a flag if there is a match and then test the flag variable to determine if you should print the the Not a city in Michigan. message. Comments in the code tell you where to write your statements. You can use the previous Mail Order program as a guide. Instructions Ensure the provided code file named MichiganCities.cpp is open. Study…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- 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

Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON

Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education