Question: *IN JAVA* ADD TO THE FOLLOWING CODE BELOW at the //add code here. FOLLOW ALL DIRECTIONS AND SHOW PROOF OF CODE WORKING 1) code to
*IN JAVA* ADD TO THE FOLLOWING CODE BELOW at the //add code here. FOLLOW ALL DIRECTIONS AND SHOW PROOF OF CODE WORKING
1) code to search for whether duplicates exist in the arrayList below and print whether or not they exist
2) Code to create a Selection Sort algorithm that sorts the elements in the arrayList based on the integers that are in the arrayList given below. Then print the arrayList after sorting it
3) Now, code to randomize the order of the objects in the arrayList given below. Print the arrayList after randomizing it.
4) Finally, code to create an Insertion Sort Algorithm that sorts the elements in the arrayList based on the integers that are in the arrayList given below. Then print the arrayList after sorting it.
import java.util.*;
class Main {
public static void main(String[] args) {
class Restaurant
{
private String food;
private int orderNumber;
private double cost;
public Restaurant(String foodName, int orderNum, double price)
{
food = foodName;
orderNumber = orderNum;
cost = price;
}
public String toString()
{
return food + ": #" + orderNumber + ": $" + cost;
}
}
ArrayList chickFilA = new ArrayList();
chickFilA.add(new Restaurant("Chick-fil-A Chicken", 1, 6.75));
chickFilA.add(new Restaurant("Chick-fil-A Nuggets", 3, 5.75));
chickFilA.add(new Restaurant("Grilled Chicken", 5, 8.15));
chickFilA.add(new Restaurant("Spicy Deluxe", 2, 7.59));
chickFilA.add(new Restaurant("Waffle Potato Fries", 10, 2.35));
chickFilA.add(new Restaurant("Grilled Cool Wrap", 8, 9.09));
chickFilA.add(new Restaurant("Chick-n-Strips", 4, 7.09));
chickFilA.add(new Restaurant("Chicken Salad Sandwich", 9, 7.69));
chickFilA.add(new Restaurant("Grilled Nuggets", 6, 7.65));
chickFilA.add(new Restaurant("Grilled Chicken Club", 7, 9.45));
System.out.println(chickFilA);
chickFilA.add(3,new Restaurant("Soup and Salad", 12, 7.19));
System.out.println(chickFilA);
chickFilA.remove(7);
System.out.println(chickFilA);
chickFilA.set(5, chickFilA.get(0));
//add code here
}
}
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
