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
Rudiy27
3 years ago
8

1 // Application contains a starting list of three products for sale2 // The user is prompted for additional items3 // After eac

h new entry, the alphabetically sorted list is displayed4 import java.util.*;5 public class DebugNine36 {7 public static void main(String[] args)8 {9 ArrayListproducts = new ArrayList();10 products.add(shampoo);11 products.add(moisturizer);12 products.add(conditioner);13 Collections.sort(products);14 display(products);15 final String QUIT = "quit";16 String entry;17 Scanner input = new Scanner(System.in);18 System.out.print("\nEnter a product or " + QUIT + " to quit >> ");19 entry = input.nextLine();20 while(entry.equals("quit"))21 {22 products.add(entry);23 Collections.sort(products);24 display()25 System.out.print("\nEnter a product or " + QUIT + " to quit >> ");26 entry = input.nextLine();27 }28 public static void display(ArrayList products)29 {30 System.out.println("\nThe size of the list is " + products.size());31 for(int x = 0; x == products.size(); ++x)32 System.out.println(products.get(x));33 }34 }35//Debugging Exercises, Chapter 9;Java Programming, Joyce Farraell, 8th

Computers and Technology
1 answer:
madam [21]3 years ago
3 0

Answer:

Here is the corrected code:

import java.util.*;

public class DebugNine36 {  //class name

  public static void main(String[] args)    {  //start of main method

     ArrayList<String>products = new ArrayList<String>();  //creates an ArrayList of type String names products

     products.add("shampoo");  //add shampoo to product array list

     products.add("moisturizer");  //add moisturizer product array list

     products.add("conditioner");  //add conditioner product array list

     Collections.sort(products);  //sort the elements in products array list

     display(products);  //calls display method by passing products array list

     final String QUIT = "quit";  //declares a variable to quit the program

     String entry;  //declares a variable to hold product/element or quit

     Scanner input = new Scanner(System.in);  //creates Scanner object

     System.out.print("\nEnter a product or " + QUIT + " to quit >> ");  //prompts user to enter a product or enter quit to exit

     entry = input.nextLine();  //reads the entry value from user

     while(!entry.equals("quit"))       {  //loops until user enters quit

        products.add(entry);  //adds entry (product) to products array list

        Collections.sort(products);  //sorts the elements in products array list

        display(products);  //calls display method by passing products arraylist

        System.out.print("\nEnter a product or " + QUIT + " to quit >> ");  //keeps prompting user to enter a product or enter quit to exit

        entry = input.nextLine();        }    }  //reads the entry value from user

  public static void display(ArrayList products)    {  // method to display the list of products

     System.out.println("\nThe size of the list is " + products.size());  //displays the size of the array list named products

     for(int x = 0; x < products.size(); ++x)  //iterates through the arraylist products

        System.out.println(products.get(x));    }  } //displays each item/element in products array list

Explanation:

In the code the following statement are corrected:

1.

ArrayListproducts = new ArrayList();

This gave an error: cannot find symbol

This is corrected to :

 ArrayList<String>products = new ArrayList<String>();

2.

         products.add(shampoo);

         products.add(moisturizer);

         products.add(conditioner);

Here shampoo moisturizer and conditioner are String type items that are to be added to the products so these strings have to be enclosed in quotation marks.

This is corrected to :

     products.add("shampoo");

     products.add("moisturizer");

     products.add("conditioner");

3.

display();

This method is called without giving any arguments to this method. The method display takes an ArrayList as argument so it should be passed the arraylist products to avoid error that actual and formal argument lists differ in length .

This is corrected to :

display(products);

The screenshot of output is attached.

You might be interested in
What is data anayltics
Lena [83]
Data analytics<span> (DA) is the science of examining raw </span>data<span> with the purpose of drawing conclusions about that information. </span>Data analytics<span> is used in many industries to allow companies and organization to make better business decisions and in the sciences to verify or disprove existing models or theories.</span>
7 0
3 years ago
In how many sections is the Add Animation pane divided? What is the utility of each section?​
NikAS [45]
It’s 45 sections they divided
3 0
3 years ago
Read 2 more answers
What is the purpose of memory address?​
IceJOKER [234]

Answer:

A memory address is a unique identifier used by a device or CPU for data tracking.

5 0
2 years ago
Read 2 more answers
14. How do digital libraries address the problem of digital exclusion?
loris [4]

The digital libraries address the problem of digital exclusion by: They reach out to people who need technology and help teach them digital literacy skills.

<h3>What does it mean to be digitally excluded?</h3>

The  digital exclusion  is known to be also as digital divide and this is known to be where a part of the population is known to possess a continuous and unequal access and capacity in regards to the use Information and Communications Technologies (ICT),

Note that IT are very essential for all to be fully participated  in the society and the digital libraries address the problem of digital exclusion by: They reach out to people who need technology and help teach them digital literacy skills.

Learn more about digital exclusion from

brainly.com/question/7478471

#SPJ1

3 0
2 years ago
To reduce costs and the environmental impact of commuting, your company decides to close a number of offices and to provide supp
kkurt [141]

Answer:

The description including its query is provided throughout the section of the elaboration elsewhere here.

Explanation:

  • Coordination between teams is the main challenge that this new strategy can make. Agile creation is focused on the teamwork of cross-functional teams, where every other mission is identified and distinct teams are formed. All the departments collaborate and afterward work in stages until the completion of this research project.
  • Unless the organization shuts several departments, contact with various teams and peers will be disrupted and contact differences with workers as well as the team would be established.
  • The best approach will be to provide regular communication calls with multiple project managers such that each project stage is synchronized. In turn, this same project coordinator should always have numerous calls with his group members to even get construction progress.
6 0
3 years ago
Other questions:
  • Is Digital technology always better or should we champion or even return to innovative of analog machines and experiences? Apex
    13·1 answer
  • Write a recursive function, replace, that accepts a parameter containing a string value and returns another string value, the sa
    5·1 answer
  • Search engine ranking evaluates the variables that search engines use to determine where a URL appears on the list of search res
    7·1 answer
  • All tif files start at offset 0 with what 6 hexadecimal characters?​
    11·1 answer
  • Write a question that the database will understand. Which records are not equal to 5? &lt; 5 &gt; 5 &gt; =5 &lt; &gt; 5
    15·1 answer
  • Suppose a process in Host C has a UDP socket with port number 6789. Suppose both Host A and Host B each send a UDP segment to Ho
    8·1 answer
  • Complete the sentence.<br> A ___ number is composed of only zeros and ones.
    8·1 answer
  • State three advantages of using a printer​
    15·1 answer
  • The identification of the technology management framework contain?
    6·1 answer
  • What are the disadvantages of vector images when compared to bitmap images?
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!