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
ELEN [110]
3 years ago
13

Exploring Arraylists. Remember that arraylists are good for adding and removing things, and that they are clock-cycle friendlier

in this case than resizing arrays as we discussed in lecture. This lab allows you to get some hands-on using an arraylist so you will remember it for those times it would be a good fit for an application. a) Create an Arraylist of type String and prompt the user for three names and add these names to your ArrayList. b) Print a message with the number of elements in the ArrayList for the user using the size() method (to find the number to print.) c) Prompt the user for two more names and add them to the ArrayList and once again print a message with the number of elements in the ArrayList for the user. d) Use a loop to print all of the names in the ArrayList for the user. e. Ask the user for a name to remove, remove the value the user provides, and then use a loop to print all of the names in the ArrayList for the user. (25 points)
Computers and Technology
1 answer:
Yuliya22 [10]3 years ago
5 0

Answer:

Code is given below:

Explanation:

import java.io.*;

import java.util.*;

import java.util.Scanner;

class Solution {

  public static void main(String args[]) {

      Scanner in = new Scanner(System.in);

     

     

      ArrayList<String> ans = new ArrayList();

     

      System.out.println("(a) ADD THREE NAMES: ");

     

      for(int i=0;i<3;i++)

      {

          ans.add(in.next());

         

      }

      System.out.println("(b) NUMBER OF ELEMENTS: " + ans.size());

     

      System.out.println("(c) ADD TWO MORE NAMES : ");

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

      {

          ans.add(in.next());

         

         

      }

      System.out.println("(d) PRINT ALL NAMES: ");

      for(int i=0;i<ans.size();i++)

      {

          System.out.println(ans.get(i));

      }

     

      System.out.println("(e) ENTER A NAME TO REMOVE: ");

      ans.remove(in.next());

      for(int i=0;i<ans.size();i++)

      {

          System.out.println(ans.get(i));

      }

     

     

  }

}

You might be interested in
To edit the text in a smartart graphic, what must be done first ?
ICE Princess25 [194]
C Hope this helps :D
8 0
2 years ago
Read 2 more answers
jelaskan tiga kemungkinan sebab pengasah pensil itu tidak dapat berfungsi secara tiba-tiba (translate: explain three possible re
boyakko [2]

Explanation:

Internal gear wear must be significant (visually obvious) to be the cause of off-center sharpening. Cutter carrier is rotating but the pencil is not sharpening (doesn't feel like the cutter is engaging the pencil) This is usually caused by a foreign object (e.g., an eraser or broken pencil lead) inside the pencil bore.

3 0
2 years ago
All of the following are types of data storage devices except CD/DVD computer monitor digital cameras flash drive
horrorfan [7]

Computer Monitors are not storage devices.

3 0
2 years ago
Mrs. Patel uses a computer program to balance her checkbook. Which of the following best explains how the
Alexandra [31]

Answer:

c it reduces errors

Explanation:

Instead of Mrs.Patel doing it she has an online program made for checks to do it for her.

6 0
3 years ago
13,Which hardware device is used in decoding the machine language version of an instruction in the Instruction Decode stage of t
Julli [10]
It should be the control unit
8 0
1 year ago
Other questions:
  • Which social media marketing concept engages visitors, getting them to revisit your website and tying them to offline events for
    7·2 answers
  • Whenever you are passing or another vehicle is passing you, _______ is particularly important to avoid collisions. A. Turning. B
    9·2 answers
  • Jennifer’s company currently uses Windows Active Directory to provide centralized authentication, authorization, and accounting
    7·1 answer
  • Using the media as equipment for living. Explain how you would use some form of media to serve a purpose in your life—and what t
    6·2 answers
  • An email address contains the @ character. Write a program that takes asks for an email address input from the user and determin
    5·1 answer
  • In C++ please.
    8·1 answer
  • Holi alguien sabe como cambiar el gamertag en XBox App (para iOS)?
    9·1 answer
  • . When attempting to minimize memory usage, the most efficient way to do group processing when using the MEANS procedure is to u
    13·1 answer
  • This site isn't letting me add my ans and wut should I do?
    15·1 answer
  • Implement a simplified version of a crypto broker platform. Initially, there is an array of users, with each user depositing onl
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!