Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

1. Build a complete Java program named TextFileShoppingLIst. From its main method, call a method named writeShoppingList. This method takes an ArrayList of five strings provided by the user at the command line. Use a loop for repeated prompting and receiving of the five strings. Each string is written as a line in a text file named names.txt . Make sure to handle the exception that might be thrown and print the error message to the command line.

2. Build a complete Java program named NamesEvaluation. From its main method, call a method named obtainNames. This method should declare an array of three first names as strings. In the method, prompt the user for each name as a string. Each string should be a first name of at least five characters (e.g. "Charles") and the first character must be received as an uppercase letter. Keep in mind a first name may be more than one word (e.g. "Mary Lou"). If a data validation isn't passed, throw an error of the Exception class. Handle the exception in a method named handleError. This method should accept a string containing a suitable message about the type of error that occurred (e.g. "The name wasn't at least five characters."). The handleError method simply prints the string it received as an argument. Keep prompting the user, if necessary, until all data validations are passed.

3. Continuing from the previous exercise, now that data validations have been enforced, pass the array of five first names to a method named searchNames. This method does not return a value. It should prompt the user for which first name they wish to display in the array as an integer (e.g. "Enter the position number of the name you wish to see: "). Use a try...catch block to prompt the user and obtain the integer. Display the matching name at that array index position as a string. Handle three potential errors via the catch block. The first should take care of a non-integer index entry. The second should take care of an index entry that is out of bounds for the array size. The third should be of an Exception type. Each raised exception should include a suitable custom message for that exception type along with the result of its .getMessage() string.

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M91923791
  • Price:- $15

Priced at Now at $15, Verified Solution

Have any Question?


Related Questions in Computer Engineering

A researcher conducts a well-designed study to compare a

A researcher conducts a well-designed study to compare a sample mean to a known population mean and uses alpha=.05, two-tailed. She finds a z-test of 1.98, p-value=.048. What should she conclude? a. The 95% confidence in ...

While you were shopping at best buy you overhear a customer

While you were shopping at Best Buy, you overhear a customer asking one of the sales staff in the store about what is the fastest computer in the store that he can buy? The staff replies, "you're looking at our AMD machi ...

Discuss how an enterprise architecture can establish

Discuss how an Enterprise Architecture can establish governance mechanisms?

On a multiple choice test there are 8 questions worth 125

On a multiple choice test, there are 8 questions worth 12.5 points each. There are four choices for each question (a,b,c,d). Robin has not studied for the quiz and decides to randomly guess on all of the questions. 1. Th ...

What are information silos what are the problems caused by

What are information silos? What are the problems caused by information silos? How organizations can solve the problems caused by information silos?

Searching algorithm - which to use for this problemthe

Searching Algorithm - Which to use for this problem? The original problem was: You get a job with a small e-commerce company. b) The customer base has grown to 8,000,000 customers. Jorge now insists that the sorting algo ...

What are information silos what are the problems caused by

What are information silos? What are the problems caused by information silos? How organizations can solve the problems caused by information silos?

Question subject digital securitybriefly explain how

Question : Subject: Digital security Briefly explain how Android 3.0 and later versions encrypt file and user data, and how encryption keys are derived. The response must be typed, single spaced, must be in times new rom ...

Research the differences in file formats between ms office

Research the differences in file formats between MS Office 2003 and MS Office 2007. Explain how file signatures and metadata can be used to determine which versions of MS Office applications (e.g. Word, Excel, Power Poin ...

Scenario you have been asked to setup a lvm volume for the

Scenario: You have been asked to setup a LVM volume for the Sales group. Your task is to use /dev/sdb to create a logical volume named sales_lvm, format it with XFS, and mount under /sales. Make sure the sales group owns ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As