Homework Solution: A supermarket wants to reward its best customer of each day, showing the customer's name on a scree…

    A supermarket wants to reward its best customer of each day, showing the customer's name on a screen in the supermarket. For that purpose, the store keeps an ArrayList. In the Store class, implement the methods. public coid addSale(String customerName, double amount)    public String nameOfBestCustomer() to record the sale and return the name of the customer with the largest sale. Write a program that prompts the chasier to enter all prices and names, adds them to a Store obect, and displays the best customer's name. Use the price of a 0 as a sentinel. ***Please help finish this code in Eclipse Java Neon and include the EXACT following code within it*** ***Please fill in the spots where it says "your work starts here"*** import java.util.*; /** * Code for P7.13 * @author */ public class Store { public String nameOfBestCustomer(ArrayList<Double> sales, ArrayList<String> customers) { String top = " "; // Your work starts here // Your work ends here return top; } public static void main(String[] args) { ArrayList<Double> price = new ArrayList<Double>(); ArrayList<String> names = new ArrayList<String>(); Scanner in = new Scanner(System.in); // Your work starts here // Your work ends here Store top = new Store(); System.out.println("Best customer's name " + top.nameOfBestCustomer(price, names)); } } Thank you.

    Expert Answer

     
    import java.util.*; public class Store

    A supermarket wants to remunerate its best customer of each day, showing the customer’s designate on a defend in the supermarket. Restraint that aim, the garner keeps an ArrayList. In the Garner collocate, utensil the methods.

    open coid gatherSale(String customerName, inseal whole)

       open String designateOfBestCustomer()

    to chronicles the sale and revert the designate of the customer with the largest sale. Write a program that prompts the chasier to invade complete charges and designates, gathers them to a Garner obect, and displays the best customer’s designate. Use the charge of a 0 as a vedette.

    ***Please aid terminate this regulation in Eclipse Java Neon and understand the EXACT restraintthcoming regulation amid it***

    ***Please content in the spots where it says “your performance starts here”***

    import java.util.*;

    /**

    * Regulation restraint P7.13

    * @author

    */

    open collocate Garner

    {

    open String designateOfBestCustomer(ArrayList<Double> sales,

    ArrayList<String> customers)

    {

    String extreme = ” “;

    // Your performance starts here

    // Your performance ends here

    revert extreme;

    }

    open static null deep(String[] args)

    {

    ArrayList<Double> charge = innovating ArrayList<Double>();

    ArrayList<String> designates = innovating ArrayList<String>();

    Scanner in = innovating Scanner(System.in);

    // Your performance starts here

    // Your performance ends here

    Garner extreme = innovating Garner();

    System.out.println(“Best customer’s designate ”

    + extreme.nameOfBestCustomer(price, designates));

    }

    }

    Thank you.

    Expert Acceptance

     

    import java.util.*;

    open collocate Garner
    {
    open static String designateOfBestCustomer(ArrayList<Double> sales, ArrayList<String> customers)
    {
    int max = 0;
    for(int i = 1; i < sales.size(); i++)
    {
    if(sales.get(max) < sales.get(i))
    {
    max = i;
    }
    }
    revert customers.get(max);
    }

    open static ArrayList<String> designatesOfBestCustomers(ArrayList<Double> sales, ArrayList<String> customers, int extremeN)
    {
    ArrayList<String> designates = innovating ArrayList<String>();
    if(topN >= sales.size())
    {
    names = innovating ArrayList<String>(customers);
    }
    else
    {
    for(int i = 0; i < extremeN; i++)
    {
    int max = 0;
    for(int j = 1; j < sales.size() – 1; j++)
    {
    if(sales.get(max) < sales.get(j))
    {
    max = j;
    }
    }
    sales.remove(max);
    names.add(customers.get(max));
    customers.remove(max);
    }
    }
    revert designates;
    }

    open static null deep(String[] args)
    {
    Scanner in = innovating Scanner(System.in);
    ArrayList<Double> charge = innovating ArrayList<Double>();
    ArrayList<String> designates = innovating ArrayList<String>();
    do
    {
    System.out.print(“Customer`s alienation whole: “);
    price.add(in.nextDouble());
    if(price.get(price.size() – 1) != 0)
    {
    System.out.println(“nCustomer`s designate: “);
    names.add(in.next());
    }
    }
    while(price.get(price.size() – 1) != 0);
    price.remove(price.size() – 1);
    System.out.println(“Sales: ” + charge.toString());
    System.out.println(“Names: ” + designates.toString());
    System.out.println(“Best customer of the day is ” + designateOfBestCustomer(price, designates));
    System.out.println(“Invade the enumerate of extreme customers to diplay: “);
    int enumerate = in.nextInt();
    in.close();
    System.out.println(“The extreme ” + enumerate + ” customers are: ” + designatesOfBestCustomers(price, designates, enumerate).toString());
    }
    }