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
Direction. List down 5 preventive maintenance tips in using tools and equipment.<br>1.​
PSYCHO15rus [73]

Answer:

Explanation:

preventive maintenance tips in using tools and equipment.

1. Inspect tools and equipment on a regular basis so as to avoid unexpected breakdown.

2. Clean tools and equipment immediately after use. It is important to wash or clean tools after using them in order to avoid clogging of dirts on them

3. Replace tools and equipment back to their respective storage place immediately after using them

4. Lubricate your tools and equipment to avoid rusting. Lubrication means to oil especially metal tools and equipments.

5. Always follow the instructions of use and maintenance of tools and equipments as stated by the manufacturer.

3 0
4 years ago
Assume that a bool variable isquadrilateral has been declared , and that an int variable , numberofsides has been declared and i
masya89 [10]
You should state the language you're using in these types of questions; here's an example in C++.

bool isQuad;
int sides;
std::cout << "How many sides does the shape have?";
std::cin >> sides;
if (sides == 4)
isQuad = true;
else
isQuad = false;
7 0
3 years ago
Why do scientists use computers to map El Nino?
Zielflug [23.3K]
El Nino is a meteorogycal phenomenom that affects certain areas . My best guess is that computers are used to map in which areas and patterns this phenomenom affects.
8 0
4 years ago
Read 2 more answers
If the web were vertical rather than horizontal, how would the frequency of oscillation be affected? a) The frequency would be h
N76 [4]

Answer:

c) The frequency would be the same.

Explanation:

The frequency of oscillation does not affected from the web being vertical rather than horizontal.

Therefore the frequency would neither be higher nor will be lower,if the web were vertical. The frequency would remain the same

8 0
3 years ago
Which operating system might cause the desktop background to change unexpectedly?
Hunter-Best [27]
I used computers for 3 years now and i think its B
4 0
3 years ago
Other questions:
  • 5255555555555+55555555555555/1111*99442
    14·2 answers
  • Computers in a medical office should be protected by which of the following security tools?
    11·2 answers
  • Your boss has asked you to edit a document she just created. You want to be able to make suggestions to the document without dir
    14·2 answers
  • 1. If your motherboard supports DIMM memory, will RIMM memory still work<br>on the board?​
    13·1 answer
  • The virus scanning technique that uses rules to determine if a program behaves like a virus is _________ scanning.
    6·1 answer
  • Advancements in nuclear science have led to technological advances which are both harmful and beneficial. Which would be conside
    15·1 answer
  • ?__________ is the term that describes devices that automate many industrial tasks by receiving digital commands and converting
    5·1 answer
  • In order for storage devices to be prepared for use, they must be ____________ Group of answer choices pre-prepared loaded initi
    11·2 answers
  • How to hack free fire dimond
    10·2 answers
  • The function retrieveAt of the class arrayListType is written as a void function. Rewrite this function so that it is written as
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!