Question
Please write program in Java: Lab9B: MicroDB. In this part of the lab, all methods will have a void return type and take in an
Please write program in Java:
Lab9B: MicroDB. In this part of the lab, all methods will have a void return type and take in an array of integers as a parameter. Write a program that creates a mini database of numbers that allows the user to reset the database, print the database, add a number to the database, find the sum of elements in the database, or quit. In the main method, you must declare an array of 10 integers (this is required). Now, you need to define these methods: printArray (int[ ] arr) this takes in an array and prints it initArray (int[ ] arr) this initializes the array so that each cell is 0 printSum (int[ ] arr) this calculates the sum of the elements in the array and prints it enterNum(int[ ] arr) this asks the user for a slot number and value putting the value into the array in the correct slot printMenu (int[ ] arr) prints the menu in the sample output Note: If you are using C++, you can pass the size of the array as a second parameter. In the main method, create an array of 10 integers then call initArray(). Now, using a loop, print the menu and ask the user to pick one of the optionscalling the appropriate method based on the users input. Every time you call a method, you need to pass the array that was created in the main method. I suggest you use a do-while loop and a switch statement in the main method. Your output should look like the sample below. User input is in bold.Page 3 of 4 Sample output #1 Would you like to: 1) Enter a number 2) Print the array 3) Find the sum of the array 4) Reset the array 5) Quit 1 Enter the slot: 5 Enter the new value: 76 Would you like to: 1) Enter a number 2) Print the array 3) Find the sum of the array 4) Reset the array 5) Quit 1 Enter the slot: 2 Enter the new value: 33 Would you like to: 1) Enter a number 2) Print the array 3) Find the sum of the array 4) Reset the array 5) Quit 2 |0|0|33|0|0|76|0|0|0|0 Would you like to: 1) Enter a number 2) Print the array 3) Find the sum of the array 4) Reset the array 5) Quit 3 109 Would you like to: 1) Enter a number 2) Print the array 3) Find the sum of the array 4) Reset the array 5) Quit 4 Would you like to: 1) Enter a number 2) Print the array 3) Find the sum of the array 4) Reset the array 5) Quit 2 |0|0|0|0|0|0|0|0|0|0 Would you like to: 1) Enter a number 2) Print the array 3) Find the sum of the array 4) Reset the array 5) Quit 5
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started