Start with your solution from the Array program below Use a

Start with your solution from the Array program below, Use a try-catch block to prevent an IndexOutOfBoundsException from occurring. Once you have added your try-catch clauses, run the Program and have the user enter 11 numbers for the array. What happens?

In this Program you will be working with Arrays.Create a new GUI, called MyArray.This program will have only 1 Form, that the user will use to enter up to 10 integer values and store these integer values in an array.Your Form should have one TextBox to enter the integers, and 3 Buttons;an “Exit” Button, an “Add Value” Button, and a “Display Values” Button.

To Add a number to the array, the user should type in a number in the Textbox and then click on the “Add value” button.

To Display the data in the Array, the user should click on the “Display Button”. When the user clicks the “Display Values” Button, you should display the values stored in the array using Console.WriteLine() to display the values in the output window.

Solution

class JavaApp1

{

public static void main(String[] args)

{

try{

void display()

{

int a[10];

System.out.println(\"Enter the number\");

int count =1

for(int i=0;i<=11;i++)

{

System.out.println (\"a[i]);

}

}

}

void formdetails()

{

int a[9];

// initalizing the text field with the size declaration

textField = new JTextField(11);

public void actionPerformed(ActionEvent evt)

{

String text = textField.getText();

textArea.append(text + newline);

textField.selectAll();

}

catch(IndexOutOfBoundsException ie)

{

System.out.println(\"Invalid value entred, greater than array size\");

}

int j;

System.out.println(\"enter the value 1,2, or 3 for adding or displaying contents\");

switch(j)

{

case :1 Add;

case: 2 display;

case: 3 Exit;

}

end case

}

void Add()

{

string text1 = textField.getText;

}

void display()

{

BufferredInputOutputReader bf = new BufferedInputOutputReader();

bf.Console.WriteLine(\"file1.txt\",append);

}

void exit()

{

bf.close();

}

}

Start with your solution from the Array program below, Use a try-catch block to prevent an IndexOutOfBoundsException from occurring. Once you have added your tr

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site