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

  Create both method contract and the method specification

Your demonstrations of how to create both method contract and the method specification for the GetCourseByCourseID() method of the CourseList class were very well received by your team members

  Implement a set as a new class that is derived

A set is like a bag, except that a set does not allow multiple copies of any element. If you try to insert a new copy of an item that is already present in a set, then the set simply remains unchanged.

  Instance methods

instance methods: setWidth(double w), setHeight(double h), double getWidth(), double getHeight() and double getArea() * A triangle's area is calculated by width*height*0.5  * all variables are private and methods public.

  Traditionally-nutrition programs were targeted to indigent

Traditionally, nutrition programs were targeted to the indigent and poor populations in developing countries. Many of today's Americans are malnourished also, but they are glutted with a wealth of unhealthy foods and require a multidisciplinary appro..

  Develop view for order number and order total in file

Develop a view named OrdTot. It comprises of order number and order total for each order currently on file. Order total is the sum of number ordered.

  Develop a java application for the local library

You have been requested to develop a Java application for the local library as part of an upgrade initiative. As in all libraries, this is a place where one can check out books

  Implement a third component of the compiler

To detect duplicate declarations using the same identifier, you call the method retrieveOneLevel. This method returns a pointer to the identifier entry if the identifier was declared before in the current scope and null otherwise.

  The code must take into account

The code must take into account leap year and adding or subtracting between years. Write two additional methods that you come with on your own as well.

  Java enumeration lettergrade represent letter grades

Write a java enumeration LetterGrade that represents letter grades A through F, including plus and minus grades. Define a private instance variable holding a boolean value.

  Design and implement a small and simple email server using

design and implement a small and simple email server using the concept of web based information system. your system

  Write the methods used in section two of main

Write the constructor for the SortTraversableLinkedList. It should create the head and tail nodes, and set the size of the list to 0, as in a typical linked list.

  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.

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