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

  Implement class that can be player in a game of tic tac toe

Specify, design, and implement a class that can be one player in a game of tic-toc-toe. The constructor should be specify whether the object is to be the first player (X's) or the second player (O's).

  Write a program that takes cents as an integer and converts

Write a program that takes cents as an integer and converts it to dollars and cents and the conversion should be done in a function called NormalizeMoney.

  Explain how the loop displaying the menu

Explain how the loop displaying the menu is exited, what value does menuSel have when the program finishes? Describe what happens next when menuSel gets this value.

  Create a program in java that displays hello world

Create a program in Java that displays "Hello world!", No Design Section is required for this assignment, Copy and Paste your code into the Source Programs section and a screen shot of the results in the Output section.

  Create a project using the classes in the doc sharing area

create a project using the classes in the Doc Sharing area labeled A Simple LinkedList class. Compile it, run it, and review the code that is given carefully. This code tests the LinkedList class provided in the lecture.

  Create the look for two gui applications

Create the look for two GUI applications. You WILL NOT be getting the applications to do anything. We are only interested in seeing how well you can arrange the GUI components onto the window

  Write a recursive method to print all permutations of string

Write a recursive method to print all the permutations of a string. For instance, for a string abc, the printout is: abc acb bac bca cab cba

  Create a complete java application

Create a complete Java application that meets these requirements and the program has an opening comments section (using block comments) with the file name, date, your name, and purpose of the program.

  Representing a topographic map

Consider a grid of size N x N that represents a topographic map. Each tile describes the characteristics of its terrain, which could be of two types: normal or mountainous. ROBBIE the robot must navigate from a starting position (xs, ys) to a goal..

  Class named stock to model a stock

Write a class named Stock to model a stock. The properties and methods of the class are shown in Figure 6.22. The metho changePercent computes the percentage of the change in the current vs. the previous closing price.

  Write a for loop that computes the sum of all integers

Write a for loop that computes the sum of all integers from 1 to 10

  String that contains at least five letters

Write an application that prompts the user for a String that contains at least five letters and at least five digits. Continuously reprompt the user until a valid String is entered. Display a message indicating whether the user was successful or did ..

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