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

  A program that reads in two integers typed on the keyboard

Write a program that reads in two integers typed on the keyboard and outputs their sum, difference, and product. Must compile correctly in Eclipse. Here is what I have done, but its wrong.

  Evaluate the total average of all the inputs

Once the user enters in the desired amount of inputs, they will then select the second button "Calculate".

  Class should have a method that returns the average

Write a class named TestScores. The class constructor should accept an array of test scores as its arguments. The class should have a method that returns the average of the test scores.

  Write a method named rowofstars

Write a method named rowOfStars that takes a single integer parameter n and returns a String with that many stars in it.

  The frantic pipe layer game1 the completed gamehere is what

the frantic pipe layer game.1 the completed gamehere is what the user interface should look like when completedyou must

  Use of java api to perform interactive i/o in java

To gain experience designing and writing your own Java Program, To use of Java APIs to perform interactive I/O in Java programming, To declare variables and constants appropriately

  Design the appropriate accessor and mutator methods

Design an Employee class that has fields for the following pieces of information: Employee Name Employee Number Next, design a class named ProductionWorker that extends the Employee class.

  Executing stringed musical instrument class

Create and execute a stringed musical instrument class.

  Java application that asks a user to enter two integers

Write a Java application that asks a user to enter two integers (A and B) and then display the results of A/B. Catch any division by zero errors and prompt the user to reenter the value of B. Be sure your code compiles and runs as expected. Name your..

  Write a java program that simulate a number of stopwatches

Write a JAVA program that would simulate a number of stopwatches (e.g. 4 stopwatches) times using the concept of Multithreading. The time of stopwatches increase on their own. Moreover, a stopwatch's time can be increased and decreased using speci..

  Write java classes for the class diagram

Write Java classes for the class diagram. You don't need to write any set and get methods for simplicity.

  A program that reads a four-digit number from the keyboard

Write a program that reads a four-digit number from the keyboard as a string and then converts it into decimal. For example, if the input is 1100, the output should be 12. Hint: Break the string into characters and then convert each character to a va..

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