Sort, Delete, Add, Smallest, & Largest of Array

    The example will have a menu of selections for the user to choose from. The program allows the user to add an element to the array, delete a specify element
from the array or simply clear everything from the array. It allows the user to find the smallest or largest element of the array. The source code is pretty long and it contains a sortedArray class, however I'll explain how the code works.

 

 

This is the main class of the program. Inside the main class, we list out the possible options that the user can select from. Here I used a do-while loop to continuously loop out the option until the user selects the EXIT option. The option menu will bring back to the screen each time a selection is done. In addition,
I used try-catch to handle any InputMismatchException, basically if the user enters anything besides an Integer, it will catch it and prints out a message Invalid
Input and the program will exit.



 

ClickHere to download IntDriver.java 

ClickHere to download SortedArray.java 

 

Note: If you are wondering what is package arrayproject, don't worry about that. If you are confused by them, remove both of the package arrayproject from your file. However, if you want to learn about it, you can google or yahoo it.

 

< Java >  <Home><Java Programs>