Write a complete java program called parser

Assignment Help JAVA Programming
Reference no: EM13865150

Write a complete Java program called Parser that gets a comma-delimited String of integers (eg "4,8,16,32,...") from the user at the command line and then converts the String to an ArrayList of Integers using the wrapper class) with each element containing one of the input integers in sequence.

Finally, use a for loop to output the integers to the command line, each on a separate line. 

import java.util.ArrayList; import java.util.Iterator; import java.util.Scanner;

public class probset5a { 

    public static void main(String[] args) { 

        ArrayList mylist = new ArrayList<>(); 

        Scanner in = new Scanner(System.in); 

        System.out.println("Enter Input String : "); 

        String inputString = in.nextLine(); 

 

        while(true) { 

            int index = inputString.indexOf(","); 

                if(index == -1) { 

                    mylist.add(Integer.parseInt(inputString)); 

                    break; 

                } 

                mylist.add(Integer.parseInt(inputString.substring(0, index))); 

                inputString = inputString.substring(index + 1); 

        } 

        System.out.println("Entered Integers are : "); 

        Iterator i = mylist.iterator(); 

            for(; i.hasNext()

        ;  )  { 

                System.out.println(i.next()); 

            } } }

Reference no: EM13865150

Questions Cloud

How we can get an electric field at an arbitrary point : Provide a brief verbal explanation of each step in your solution. State where the formulas are coming from, and why they are applicable here - Explain in words how we can get an electric field at an arbitrary point.
Outline the implentation of the program : Outline the implentation of the program
The exchange rate difficulties experienced by countries : Did the exchange rate difficulties experienced by countries under the ERM strengthen or weaken the arguments for progressing to a single European currency?
Compare and contrast the national interests : Compare and contrast the national interests
Write a complete java program called parser : Write a complete Java program called Parser that gets a comma-delimited String of integers  (eg "4,8,16,32,...") from the user at the command line and then converts the String to an ArrayList of Integersusing
That just some of the members of a common market like the e : Assume that just some of the members of a common market like the EU adopt full economic and monetary union, including a common currency. What are the advantages and disadvantages to those members joining the full EMU and to those not?

Reviews

Write a Review

JAVA Programming Questions & Answers

  Java program using jgrasp and the software development kit

Design a GUI program to find the weighted average of four test scores. The four test scores and their respective weights are given in the following format:

  Prepare a polynomial-time algorithm

Write a polynomial-time algorithm that, given an initial configuration (P_1, P_2, ..., P_k), decides if it is a winning configuration - Prepare a polynomial-time algorithm that decides if it is a winning configuration.

  Create a class named date that stores date values

Create a class named Date that stores date values

  Describe the equivalence classes

Prove that these relations on the set of all functions from Z to Z are equivalence relations. Describe the equivalence classes.

  Inheritance involves the concept of super class

Inheritance involves the concept of super class (parent class) and sub class (derived class). What is a super class in Java? What is a sub or derived class in Java?

  Prepare a class called geometrycalculator

Calculates the area of a circle of a given radius and write a class called GeometryCalculator that includes the subsequent methods

  Write java program to print strings given at command line

Write a program Average.java which just prints strings that it is given at command line, one per line. If nothing is given at command line, print "No arguments".

  Write a java program that demonstrates exception handling

For this project, you will write a Java program that demonstrates exception handling. Your program will accept from the user ten values and place those numbers in an array

  Integers as a parameter and returns the number

Write a method maxOccurrences that accepts a list of integers as a parameter and returns the number the number of times the most frequently occurring integer

  Create a new android application project

You have been hired to create a mobile application for Healthy Life, a local organic bakery and grocery store. The main screen should state the name of the person who owns the phone. Create a new Android Application Project

  Implement a game of tic-tac-toe

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

  Marketing necessary for practice-hospital to successful

Why is marketing necessary for a practice or hospital to be successful? What considerations should be taken into account when marketing health care services or products? (Hint think about all the medication ads you seen on tv or in magazines)

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