Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program for the following. NOTE that some of these steps are not dependent on each other. Using method will make your life much

Write a program for the following. NOTE that some of these steps are not dependent on each other. Using method will make your life much easier as you develop your code:

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 5 random integers. Prompt the user to enter the index of the array and display the corresponding element value. If the specified index is out of bounds, throw an exception and display the message out of bounds.

C) Create an array with 10 elements and populate it with 10 random numbers. Ask the user for the name of an output file. Write your full name as the first line of the file and the contents of the array to this file. If the file exists, tell the user that the file exists and do not write to the file. HINT: see page 476 (chapter 12) listing for WriteData.java.

D) Write the code to create a text file named text.txt. Write the following text to the file: All men (and women) are created equal!

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 a method and use it 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 the file text.txt created in step d. HINT: A word is separated by one space, so number of spaces should give you a clue.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Management System MCQs Multiple Choice Questions And Answers

Authors: Arshad Iqbal

1st Edition

1073328554, 978-1073328550

More Books

Students also viewed these Databases questions

Question

LO2 Compare three types of individual incentives.

Answered: 1 week ago