Display all of the elements of the arraylist

Assignment Help JAVA Programming
Reference no: EM13940032

The following code creates a simple ArrayList:

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
public class Ex01 {
public static void main(String[] args) throws IOException {
BufferedReader userInput = new BufferedReader
(new InputStreamReader(System.in));
ArrayList<String> myArr = new ArrayList<String>();
myArr.add("Zero");
myArr.add("One");
myArr.add("Two");
myArr.add("Three");
}
}
Starting with this provided code, add the following functionality:

1. Add items to the ArrayList, one at a time, based on user typed input. The user will be prompted for the String to be stored in the ArrayList and then hit enter. The user will be able to continue to add items to the ArrayList until they just hit enter without typing anything.

2. Once the user does this (hits enter without typing anything), the program will display all of the elements of the ArrayList, both the index and String values, in a table. It will do this via a single loop.

Reference no: EM13940032

Questions Cloud

Understanding of the nature and extent of problem : In your answer, you will need to demonstrate some understanding of the nature and extent of the 'problem' before applying your chosen sociological theory. You will need to use at least 8 authoritative sources (journal articles, textbooks, etc.)
Compute the number of units of each product : The selling prices are $30 for squares and $50 for circles. Compute the number of units of each product that must be sold for Gosnell Company to break even.
A new business venture producing teddy bears : Peter Jones, is looking to set up a new business venture producing Teddy Bears. He has some good contacts in the retail sector and expects to be able to produce and sell 20,000 units per month, for the foreseeable future.
Code that sorts the household sizes in ascending order : The program should allow the user to enter each household size and determine the mean and median household size in Marengo. Need to write the code that sorts the household sizes in ascending order using a bubble sort.
Display all of the elements of the arraylist : Once the user does this (hits enter without typing anything), the program will display all of the elements of the ArrayList, both the index and String values, in a table. It will do this via a single loop.
Identify the objectives of the activity : 1. Provide a brief description of the activity for which the risk management process will be applied. Be clear and concise, indicating the exact aim of the activity 2. Identify the objectives of the activity (the risk identification exercise in Pa..
How would you determine reasonable : Assume that you are the chair of the PGA Rules Committee. Following the Martin decision (PGA Tour,Inc V Martin 531 U.S. 1049 2001), you are charged with reviewing the rules and developing a policy on how to determine reasonable accommodation. What..
Find the margin of error : Find the critical value for zα/2 that corresponds to a degree of confidence of 98%. Find the margin of error for the 95% confidence interval used to estimate the population proportion with n = 163 and x = 96
Proposals using the calculations above to explain : Jamie Oliver is considering expanding his restaurant trade. He has the following two proposals to consider. A minimum of a 12% return on investment is required from the recommended project.

Reviews

Write a Review

JAVA Programming Questions & Answers

  What was in mind of the coder in each part of the code

Need a video that goes through all this java code - as if it was a tutorial showing it line by line - and explain in detail the structure of it all as if you code it yourself.

  Evaluate total annual compensation of a salesperson

Write a Java application using NetBeans Integrated Development Environment (IDE) that calculates the total annual compensation of a salesperson. Consider the following factors: A salesperson will earn a fixed salary of $45,000

  One acre of land is equivalent to

One acre of land is equivalent to 43,560 square feet. Write a program that calculates the number of square feet in a tract of land with 3.5acres.

  Define a class called counter

Define a class called Counter. An object of this class is used to count things, so it records a count that is a non negative whole number. Include methods to set the counter to 0, to increase the count by

  Which parts of the assignment were you not able to complete

Which parts of the assignment were you not able to complete fully? For each, explain why you were unable to complete this part and what steps you took to attempt to complete it. Give me as much detail as possible such that I may award partial cred..

  Point of sale terminal

a software implementation of a Point of Sale terminal at a typical store. The users of the system are the cashiers sitting at the sales terminals of the store. The users can use the system to manage sales items in the store, customer details and of c..

  Socket programming in java: tcp

In this project we will develop a Web server in two steps. In the end, you will have built a multi-threaded Web server that is capable of processing multiple simultaneous service requests in parallel.

  Write a gui program that maintains a set of contacts

Write a GUI program that maintains a set of contacts. Each contact has name, address, and a list of phone numbers. This contacts should be be stored in a HashMap

  Employee type and the number of hours

Write a program that calculates the salary for the employee. The hourly rate for permanent staff (P) is 200, contract staff (C) is 150 and temporary staff (T) is 100. The program accepts the employee type and the number of hours the employee work.

  Calculate the percentage wins of a team

Write a program that will calculate the percentage wins of a team. The program will input the number of wins and losses that a team acquired during a season. The wins should be input in a parameter-less value returning function that returns the wi..

  Calculate rental fee for different types of borrowable media

Assume that there is an abstract class called Vehicle, which has two concrete subclasses, Car and Truck. There is also an interface Loadable, which only Truck implements - calculate a rental fee for different types of borrowable media (e.g. books,..

  Distributed systems

Build robust, secure distributed systems using advanced programming techniques

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd