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
What are the five types of alignment in Word?
Basile [38]
There are four types of alignment in word.
Left-aligned text
Right-aligned text
Center-aligned text
Justified text
6 0
4 years ago
Read 2 more answers
Help wat does ctrl+u means
Anastasy [175]

Answer:

crtl+u is a shortcut.

Explanation:

Microsoft Windows/KDE/GNOME:

underline

Unix (command line and programs using readline):

Cut text between beginning of line and cursor

3 0
3 years ago
explain the following joke: “There are 10 types of people in the world: those who understand binary and those who don’t.”
BigorU [14]

It means that there are people  who understand binary and those that do not understand it. That is, binary is said to be the way that computers are known to express numbers.

<h3>What is the joke about?</h3>

This is known to be a popular  joke that is often  used by people who are known to be great savvy in the field of mathematics.

The joke is known to be one that makes the point that a person is implying that the phrase is about those who only understands the decimal system, and thus relies on numbers in groups of 10.

The binary system is one that relies on numbers that are known to be  in groups of 2.

Therefore, If the speaker of the above phrase is one who is able to understand binary, that person  would  be able to say that that the phrase  is correctly written as  "there are 2 types of people that understand binary".

Learn more about binary from

brainly.com/question/21475482

#SPJ1

8 0
2 years ago
The overall cost of wiring in addressable fire alarm system is significantly cheaper than the conventional one. Why is it so?
stellarik [79]

Answer:

Yes, The overall cost of wiring in addressable fire alarm system is significantly cheaper than the conventional one.But the addressale fire alram system is more reliable than a conventional system.

Explanation:

Conventional systems are hardware-based and use analog technology. where addressable fire alarm use digital technology. addressable system is generally more reliable than a conventional system mainly due to how the different systems are wired. With a conventional system, if a device’s wire is damaged or severed, its signal and the signal of other devices down the line cannot be transmitted to the control panel.

With an addressable system, both ends of the wire connect to the control panel. Therefore, if one end becomes damaged or severed, signals can still reach the control panel through the other end of the loop. In addressable systems, a device can be removed or disabled and it will not affect the other devices in the loop.

7 0
3 years ago
You will complete 3 tasks. Task 1: Determine if the input number is prime or not You will ask the user for an integer You will d
GuDViN [60]

Answer:

Program is written in C++

#include<iostream>

using namespace std;

int main()

{

//1. Prime Number

int num;

cout<<"Input Number: ";

cin>>num;

int chk = 0;

for(int i =2; i <num;i++)

{

 if(num%i==0)

 {

  chk = 1;

  break;

 }

}

if(chk == 0)

{

 cout<<num<<" is prime"<<endl;

}

else

{

 cout<<num<<" is not prime"<<endl;

}

//2. Greatest Common Factor

int num1, num2, x, y, temp, gcf;  

cout<<"Enter two numbers: ";

cin>>num1;

cin>>num2;

x = num1;

y = num2;

while (y != 0) {

   temp = y;

   y = x % y;

   x = temp;

 }

 gcf = x;

 cout<<"Greatest Common Factor: "<<gcf<<endl;

 

// 3. LCM  

cout<<"Enter two numbers: ";

cin>>num1;

cin>>num2;

x = num1;

y = num2;

while (y != 0) {

   temp = y;

   y = x % y;

   x = temp;

 }

 gcf = x;

 int lcm =(num1 * num2)/gcf;

cout<<"Least Common Multiple: "<<lcm<<endl;

return 0;

}

Explanation:

<em>I've added the full source code as an attachment where I make use of comments to explain some lines</em>

Download cpp
6 0
3 years ago
Other questions:
  • Universal Windows Platform is designed for which Windows 10 version?
    7·1 answer
  • Write down the pseudo code of a program that calculates the Body Mass Index (BMI) of
    9·1 answer
  • ___ is the amount of data that a storage device can move from the storage medium to the computer per second.
    11·1 answer
  • When you are using remote control services and need to enter the ip address of the system you want to control, you should use th
    6·1 answer
  • What is the best way to set up the spreadsheet? List each expense in a row. List each income source in a column. List each expen
    15·2 answers
  • Why concurrency control is needed in transaction.
    5·1 answer
  • Long Answer Questions: a. Briefly explain the types of Control Structures in QBASIC.​
    5·1 answer
  • Moving your Sprite top to bottom is moving along the X coordinate?<br><br> True<br> False
    5·2 answers
  • Hurry i need help What would provide structured content that would indicate what the code is describing ?
    12·1 answer
  • PLEASE HELP!!! NO LINKS!! I'LL GIVE BRAINLIEST!!
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!