Question: [JavaFX/ Exception handing and text I/O] 1. Write a program for the following. NOTE that some of these steps are not dependent on each other.
[JavaFX/ Exception handing and text I/O] 1. Write a program for the following. NOTE that some of these steps are not dependent on each other. Using methods is mandatory. Make sure to use methods where it makes sense.
a. Ask the user for a series of integers entered from the keyboard. Use a sentinel value such as 999 to end the input process. If the entered values are not integers, throw an exception and ask the user again making sure that only integers are allowed as input. Note that the user could enter a floating point number or a number that has characters in it.
b. Create an array with 10 random integers between 100 and 1000, inclusive. Prompt the user to enter the index of the array and display the corresponding element value, in addition to the random integers in the array. If the specified index is out of bounds, throw an exception and display the message out of bounds. HINT: IndexOutOfBoundsException will catch such errors.
c. Create an array with 10 elements and populate it with 10 random numbers between 1000.0 and 2000.0. Note these include decimal numbers. Ask the user for the name of an output file. Write your own full name (do not ask for input) as the first line of the file and the contents of this array to this file. If the file exists, tell the user that the file exists and do not write to the file. Make sure to also ask the user to enter the file name.
d. Write the code to create a text file named text.txt. Write the following text to the file: Never trust a computer you can't throw out a window.
e. Write code to verify if the above file exists using try/catch block. If the file exists, read it, and display the contents of the text file on the screen. If the file does not exist, display an error message.
f. Write code to display the number of vowels (a, e, i, o, u case insensitive), the number of upper case letters, the number of lower case letters, the number of digits, and the number of words in a file. The user should be able to enter any file name for processing. HINT: A word is separated by one space, so number of spaces should give you a clue.
2 Write a JavaFX program to display 5 labels and 3 buttons. You can use any kind of Pane you like to use. Display 3 red circles and 2 blue rectangles (pick your own size). Use the Image and ImageView classes (explained in section 14.9 of your textbook) to show 2 images of your choice. Include a name "Lucus Night" somewhere on the frame, label, button, etc. We wont discuss handing events where one would be able to click buttons and expect results.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
