Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

*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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Sams Teach Yourself Beginning Databases In 24 Hours

Authors: Ryan Stephens, Ron Plew

1st Edition

067232492X, 978-0672324925

More Books

Students also viewed these Databases questions

Question

Be familiar with the basic ways to manage capacity.

Answered: 1 week ago