ComputerScienceExpert

(11)

$18/per page/

About ComputerScienceExpert

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Applied Sciences,Calculus See all
Applied Sciences,Calculus,Chemistry,Computer Science,Environmental science,Information Systems,Science Hide all
Teaching Since: Apr 2017
Last Sign in: 103 Weeks Ago, 3 Days Ago
Questions Answered: 4870
Tutorials Posted: 4863

Education

  • MBA IT, Mater in Science and Technology
    Devry
    Jul-1996 - Jul-2000

Experience

  • Professor
    Devry University
    Mar-2010 - Oct-2016

Category > Programming Posted 06 May 2017 My Price 8.00

Replace hard coded strings “Zero”, “One”, “Two”, “Three”

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. 1) Replace hard coded strings “Zero”, “One”, “Two”, “Three” in the ArrayList  based on user typed input (use Scanner or JOptionPane classes).  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. 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 making use of an iterator method.

Answers

(11)
Status NEW Posted 06 May 2017 04:05 AM My Price 8.00

-----------

Not Rated(0)