Question: *IN JAVA* add to the following code given below. Using the code below FIRST create code to search for the minimum value of just the
*IN JAVA* add to the following code given below. Using the code below FIRST create code to search for the minimum value of just the doubles in the ArrayList and display it. Then create code to search for the maximum value of just the integers in the ArrayList and display it. After that code to find the average length of all the Strings within the ArrayList and display it. Then search for any duplicates and whether they are next to each other in the ArrayList and display it. Then determine which integers in the ArrayList are divisible by 3 and display them. Then code to reverse the order of the ArrayList. After that, shift the arrayList right by 2 indices, making sure to wrap the elements around to the other end. After that, search the new arrayList for all occurrences of the letter 'e' and display how many there are total. After that, sort the elements in the ArrayList using a selection sort based on the doubles. Then after that, randomize the order of the objects that are created in the ArrayList. Finally, sort the elements in the ArrayList using an insertion sort based on the doubles.
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 starting 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
