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
Which one of these do you need to become president of the US ?
gladu [14]

Answer:

Tbh i dont even know

Explanation:

I had who i wanted to become president but i don't even know anymore

7 0
2 years ago
Read 2 more answers
Define function print_popcorn_time() with parameter bag_ounces. If bag_ounces is less than 3, print "Too small". If greater than
Lynna [10]

Answer:

def print_popcorn_time(bag_ounces):

 if bag_ounces<3:

   print("Too Small")

 elif bag_ounces>10:

   print("Too Large")

 else:

   bag_ounces = bag_ounces*6

   print("%s Seconds\n" % bag_ounces)    

Explanation:

  • Using Python Programming Language
  • The function is defined to accept an int parameter
  • Within the function body, if...elif and else statements are used to print the desired output
  • note the use of the %s placeholder (formated output) and \n for a new line in the final print statement
4 0
3 years ago
Dropbox and Microsoft's OneDrive are both popular applications for storing files. What is a fundamental difference between Dropb
Paha777 [63]

The difference is that Dropbox  offers just 2 GB free storage space while  Microsoft's OneDrive gives 5 GB in terms of free storage space.

<h3>What is Microsoft OneDrive?</h3>

This  is known to be a file hosting software and it also does synchronization service given by Microsoft.

Some other  fundamental difference between Dropbox and OneDrive in terms of  Business is that Dropbox is known to often give unlimited storage for about $20 to paid user/month while OneDrive is said to only give unlimited storage for $10 per paid user/month.

Learn more about Dropbox from

brainly.com/question/20935392

5 0
2 years ago
How do you hack a iPhone, Like If you forgot your password and want to get back in your phone. What do you do?
s344n2d4d5 [400]

Answer:

fix it on itunes

Explanation:

or get a new one

6 0
3 years ago
Read 2 more answers
Which of the following is a Layer 3 protocol designed to permit routers to exchange information about networks that are reachabl
Nikolay [14]

Answer:

a. Routing protocol

Explanation

Routing protocol is a layer 3 (Network layer) protocol used by routers to exchange information about available routes , their associated costs and delays.

5 0
3 years ago
Read 2 more answers
Other questions:
  • . When you create a template class, ___________.
    15·1 answer
  • Task 2 Design a 1st order low-pass filter with cutoff frequency 1kHz, 1) with roll-off and 2) without roll-off. For each filter,
    10·1 answer
  • Peter has recently bought a media player and a digital camera he wants to buy a memory card and then use devices which memory do
    11·2 answers
  • 12) If the image's name is filename.gif, how can I make this image the background of my page?
    6·1 answer
  • Literally no one helps answer my questions so this website is pointless.... : /
    11·1 answer
  • Define the instance method inc_num_kids() for PersonInfo. inc_num_kids increments the member data num_kids. Sample output for th
    6·1 answer
  • How do you write a multiplication formula in excel with an absolute refrence?
    11·1 answer
  • When you sign in to your Microsoft account with another Windows device, your settings will appear very differently than they do
    7·1 answer
  • What is the descriptor for a filter that warns or blocks you from potentially fraudulent or suspicious websites?.
    5·1 answer
  • the first thing to do when your computer gives you an error message is A restart the computer B press the F2 key C write down th
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!