Could someone please help me to make this loop? I want the user to have the option to continue Y/N at the end of the program to rerun or terminate it. Preferably a do-while loop?
CODE (Java):
public static void main(String[] args) {
int size = 10; //size of array
Scanner scan = new Scanner(System.in); //create scanner
while (true)
{
System.out.println("Enter values: ");
int[] myArray = new int[size]; //declare array
for(int i = 0; i < size; i++)
{
int userInput = scan.nextInt(); //receive user input
myArray[i] = userInput;
}
System.out.print("You entered these values: "); //print all values entered by user
for (int i=0; i<myArray.length; i++)
{
System.out.print(" " + myArray[i]);
}
System.out.println("");
IndexOfLargestBatista Object = new IndexOfLargestBatista(); //object of IndexOfLargest class
System.out.println("Index of Largest value: " + Object.findIndex(myArray)); //pass array as parameter and get index number in return
}