The restockSeed() method takes in one integer array parameter, inventory. Complete restockSeed() to declare an array with a copy of each element in inventory plus 8. Then, return the new array.
Added by William W.
Step 1
g., int[] restock = new int[inventory.length]; Show more…
Show all steps
Your feedback will help us improve your experience
Gabriel Eduok and 68 other AP CS educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
Hands-on Activity: Arrays Objective: At the end of the exercise, the students should be able to: - Create arrays in a program - Access array elements - Perform array operations - Use the Array class. Materials: - NetBeans IDE 8.2 - Java Development Kit (JDK) 8 Instructions: 1. Create a folder named LastName_FirstName (ex. Diaz_Jess) on your local drive. 2. Using NetBeans IDE, create a new project. 3. Name the class as SeatReservation and save the project in your folder. 4. Write a simple bus seat reservation program. The bus has 10 rows, with 4 seats in each row. The program should perform the following: - Step 1. The program should ask the user to enter what row and seat number to reserve. Indicate an 'X' mark if the seat is reserved. - Step 2. Repeat Step 1; the program will stop until the user enters a negative number. 5. Compile and execute the program. 6. Debug syntax and logical errors, if there are any in the program. 7. Inform your instructor once you are done. 8. The following is the example output: Bus Seat Reservation: Col 1 Col 2 Col 3 Col 4 Row 1 | * * * * Row 2 | * * * * Row 3 | * * * * Row 4 | * * * * Row 5 | * * * * Row 6 | * * * * Row 7 | * * * * Row 8 | * * * * Row 9 | * * * * Row 10 | * * * * Enter row and column number to reserve separated by space (Enter a negative number to exit): 4 3 Figure 1. First seat reservation sample output
Gabriel E.
Write a program that manages a list of up to 10 players and their high scores in the computer's memory. Use two arrays to manage the list. One array should store the players' names, and the other array should store the players' high scores. Use the index of the arrays to correlate the names with the scores. Your program should support the following features: a. Add a new player and score (up to 10 players). b. Print all the players' names and their scores to the screen. c. Allow the user to enter a player's name and output that player's score or a mes- sage if that player's name has not been entered. d. Allow the user to enter a player's name and remove the player from the list. Create a menu system that allows the user to select which option to invoke.
Akash M.
One of the programs that you wrote this semester was "Eight numbers in a cross." The problem was to write a program which allocates the integers 1-8 to the squares in the figure above, subject to the restrictions that no two adjacent squares contain consecutive integers. By adjacent, we mean vertically, horizontally, or diagonally. Say we label the eight "boxes" as follows: In the above diagram, the numbers 0-7 in the boxes are not the values in the boxes but the "names" of the boxes. Given the labeling of the boxes of the cross as above, fill in the helper array below. You must write them in the right order or no point. For example, if 1 and 3 should be checked, write 1,3,-1 and not 3,1,-1. Do not forget to fill in the number of columns! int a[8][ ]={ {-1}, //box 0 { }, //box 1 { }, //box 2 { }, //box 3 { }, //box 4 { }, //box 5 { }, //box 6 { }, //box 7 };
Sri K.
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
Watch the video solution with this free unlock.
EMAIL
PASSWORD