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
My laptop screen is flashing colors all of the sudden, how can I solve this problem? Also why is this happening is it software o
MatroZZZ [7]

Explanation:

To determine whether a display driver or app is causing the problem,check to see if Task Manager flickers. ... Then, based on that information, you'll need to update, rollback, or uninstall your displ

यह निर्धारित करने के लिए कि क्या कोई डिस्प्ले ड्राइवर या ऐप समस्या पैदा कर रहा है, यह देखने के लिए जांचें कि क्या कार्य प्रबंधक फ़्लिकर करता है। ... फिर, उस जानकारी के आधार पर, आपको अपने डिस्प्ले को अपडेट, रोलबैक या अनइंस्टॉल करना होगा

i think this can help you

7 0
3 years ago
Whats the difference between copying a file to my desktop and creating a shortcut?
hram777 [196]
When you copy a file to the desktop you are putting the actual file on the desktop whereas when you put a short cut on the desktop you are just placing a reference to where the file is actually located.
3 0
3 years ago
The packet storm web site includes a large collection of packaged shellcode, including code that can:_____.
elena55 [62]

The packet storm web site includes a large collection of packaged shellcode, including code that can create a reverse shell that connects back to the hacker, flush firewall rules that currently block other attacks, and set up a listening service to launch a remote shell when connected to.

6 0
2 years ago
In which genre of games do players most often have the power to shape how the story will end?
Dennis_Churaev [7]

Role playgames are the most customizable

4 0
3 years ago
Read 2 more answers
Some of the items below indicate the steps required to move a slide to a different location in a presentation. Select those step
Ivan

Answer:

Following is the order of steps needed to move a slide to different location:

First: Select the slide

Second: Hold the slide button down

Third: Drag the slide to the desired place.

N/A : Enter the slide position desired.

N/A: Select Move from the Tools menu.

N/A: Switch to the Notes view.

I hope it will help you!

8 0
3 years ago
Other questions:
  • Danny is editing the text content of a single page on a website he created a year ago. What part of the tag would he have to upd
    11·1 answer
  • Flesh out the body of the print_seconds function so that it prints the total amount of seconds given the hours, minutes, and sec
    12·1 answer
  • What letter names the drive where windows most commonly stores data and files
    13·1 answer
  • Create a class named Circle with fields named radius, diameter, and area. Include a constructor that sets the radius to 1 and ca
    7·1 answer
  • Edhesive 1.7 code practice question 1
    8·1 answer
  • Date Class Constructor – assigns fields to appropriate formal parameter – using the setters so error checking will occur. The co
    6·1 answer
  • A local bank has just one branch. It sets up a peer-to-peer network for all devices on the system. The bank would like to be abl
    12·1 answer
  • What type of data causes concern for institutions are businesses Lincoln elected stored and not secured properly
    6·1 answer
  • When using a self-contained recovery device on a cfc, hcfc, or hfc system with an operating compressor, technicians must?
    6·1 answer
  • 1.1 what is the osi security architecture? 1.2 what is the difference between passive and active security threats? 1.3 list and
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!