Question: 1. Write a Java program to declare an integer array of size 5. Write a menu-driven program to insert elements in the array in descending

 1. Write a Java program to declare an integer array of

1. Write a Java program to declare an integer array of size 5. Write a menu-driven program to insert elements in the array in descending order and remove them. Take the elements from the user for insertion and deletion. Do not use any in-built Java method. Consider all possible cases of insertion and deletion. Print the array after each insertion and deletion operation. You can use the Java Scanner class to take elements from the user. The sample input/output is given below: Sample input/output: (User's input is shown in bold) Press 1 to insert an element Press 2 to delete an element Press 3 to terminate the program Enter your choice: 2 Array is empty. Deletion is not possible. Enter your choice: 1 Enter a number to insert: 5 The array elements: 5 Enter your choice: 1 Enter a number to insert: 8 The array elements: 85 Enter your choice: 2 Enter a number to remove: 4 Element is not found. Enter your choice: 2 Enter a number to remove: 8 The array elements: 5 To be sent in .java format

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!