Answered step by step
Verified Expert Solution
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 LOOK AT PICS
*IN JAVA* ADD TO THE FOLLOWING CODE BELOW at the //add code here. FOLLOW ALL DIRECTIONS AND SHOW PROOF OF CODE WORKING LOOK AT PICS FOR CODE GIVEN
1) 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
2Now, code to randomize the order of the objects in the arrayList given below. Print the arrayList after randomizing it.
3Finally, 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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started