1) Specify, design and implement aclass that can store an array of integer. The
ID: 3610981 • Letter: 1
Question
1) Specify, design and implement aclass that can store an array of integer. The number of Maximumelement can be 100. Write methods to :
a. Add an integer at thebeginning of the array
b. Add an integer at the end ofthe array
c. Remove an integer at thebeginning of the array
d. Remove an integer at the end ofthe array
e. Insert an integer at anylocation except beginning and end
f. Remove an integerat any location except beginning and end
Write the Main program to get integer from the keyboard, get thechoice to where it should be added or deleted from the keyboard.After each operation print the array on the screen.
Explanation / Answer
import java.io.*; public class ArrayMax{ public static int[] array= new int[100]; public static void insertBegin(int number) { array[0] = number; } public static void insertEnd(int number) { array[99] = number; } public static void removeBegin() { array[0] = 0; } public static void removeEnd() { array[99] = 0; } public static void display() { for(int i=0; iRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.