1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
nadya68 [22]
3 years ago
14

Prompt the user for data points. Data points must be in this format: string, int. Store the information before the comma into a

string variable and the information after the comma into an integer. The user will enter -1 when they have finished entering data points. Output the data points. Store the string components of the data points in an ArrayList of strings. Store the integer components of the data points in a second ArrayList of integers. (4 pts)
Computers and Technology
1 answer:
stiks02 [169]3 years ago
8 0

Answer:

In Java:

import java.util.*;

public class Main{

public static void main(String[] args) {

    Scanner input = new Scanner(System.in);

    ArrayList<String> Strs = new ArrayList<String>();     ArrayList<Integer> Ints = new ArrayList<Integer>();

    String datapoint;

    System.out.print("Data point (0 to quit): ");

    datapoint = input.nextLine();

    while(!"0".equals(datapoint)){

        System.out.println("Data point: "+datapoint);

        String[] datapointSplit = datapoint.split(", ");

        Strs.add(datapointSplit[0]);

        Ints.add(Integer.parseInt(datapointSplit[1]));

        System.out.print("Data point (0 to quit): ");

        datapoint = input.nextLine();     }  

    System.out.println("Strings: "+Strs);

    System.out.println("Integers: "+Ints);

}}

Explanation:

In Java:

Declare string and integer array lists

    ArrayList<String> Strs = new ArrayList<String>();     ArrayList<Integer> Ints = new ArrayList<Integer>();

Declare datapoint as string

    String datapoint;

Prompt the user for data point (An entry of 0 ends the program)

    System.out.print("Data point (0 to quit): ");

Get the data point

    datapoint = input.nextLine();

This is repeated until an entry of 0 is entered

    while(!"0".equals(datapoint)){

This prints the datapoint

        System.out.println("Data point: "+datapoint);

This splits the datapoint to 2

        String[] datapointSplit = datapoint.split(", ");

This adds the string part to the string array list

        Strs.add(datapointSplit[0]);

This adds the integer part to the integer array list

        Ints.add(Integer.parseInt(datapointSplit[1]));

Prompt the user for another entry

<em>         System.out.print("Data point (0 to quit): ");</em>

<em>         datapoint = input.nextLine();     }  </em>

Print the string entries

    System.out.println("Strings: "+Strs);

Print the integer entries

    System.out.println("Integers: "+Ints);

You might be interested in
Andrew has data in cell E14 and the cell should be blank. Andrew should _____.
denpristay [2]
Use the mouse to click on cell E14 and press delete
4 0
4 years ago
Read 2 more answers
Any mobile devices contain a(n) ___ and gyroscope that can sense even the smallest movements.
mars1129 [50]

Any mobile device contains a(n) accelerometer and gyroscope that can sense even the smallest movements.

<h3>What are accelerometers? What does an accelerometer sensor do in mobile phones?</h3>

The orientation of a mobile phone is determined by the accelerometer in the device. The gyroscope, or gyro for short, tracks rotation or twist to provide another dimension to the data provided by the accelerometer.

A smartphone's built-in accelerometer measures the device's acceleration. It tracks the different motions like shaking, tilting, swinging, and rotating and accordingly changes the orientation of your app. The accelerometer utilizes the value of XYZ to determine and detect motion.

To know more about accelerometer , Visit:

<u>brainly.com/question/27960990</u>

#SPJ4

7 0
2 years ago
1. Who was able to complete the puzzle the fastest in Trial 1?
KATRIN_1 [288]

Answer:

You...answered all of the questions.

Explanation:

All of them have a response!

8 0
3 years ago
What would you NOT use a router for? *
Alla [95]

Answer:

<h2><u>A</u><u>.</u><u> </u><u>To</u><u> </u><u>run</u><u> </u><u>applications</u><u> </u><u>on</u><u> </u><u>your</u><u> </u><u>computer</u></h2>

3 0
3 years ago
How many basic elements of QBASIC are there
Masteriza [31]
<h2>6</h2>

The elements used in Qbasic:

  • Character set.
  • Variables.
  • Constants.
  • Operator and Operands.
  • Expression.
  • Statements.
6 0
3 years ago
Other questions:
  • What must be done if the intended destination hardware is not supported by the chosen OS?
    6·1 answer
  • There are varying definitions for the term "dumb terminal," but it often refers to the fact that the terminal has
    13·1 answer
  • Pros and cons of access to a wide range of online services when it comes to an individual's safety?
    14·1 answer
  • Which website can help you find antivirus software ?
    10·1 answer
  • Who creates Virus ? virus is not made for what?
    14·2 answers
  • Differentiate Between register and Memory location (
    13·1 answer
  • A program that allows employees to choose their starting and ending times, as long as they are at work during a specified core p
    8·1 answer
  • Write about virus in five points.​
    8·1 answer
  • Which tab on the ribbon in the folder window allows users to change how the contents of the folder are being shown?
    11·1 answer
  • __________ is a computer tool for evaluating the risk of exposure to wildfires.
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!