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 compensate its best customer of each day, showing the customer’s designate on a protect in the supermarket. Ce that intention, the hoard keeps an ArrayList. In the Hoard systematize, tool the methods.

    generally-known coid gatherSale(String customerName, embrace totality)

       generally-known String designateOfBestCustomer()

    to annals the sale and reappear the designate of the customer with the largest sale. Write a program that prompts the chasier to invade every worths and designates, gathers them to a Hoard obect, and displays the best customer’s designate. Use the worth of a 0 as a keeper.

    ***Please succor conclude this adjudication in Eclipse Java Neon and comprise the EXACT cethcoming adjudication amid it***

    ***Please store in the spots where it says “your composition starts here”***

    import java.util.*;

    /**

    * Adjudication ce P7.13

    * @author

    */

    generally-known systematize Hoard

    {

    generally-known String designateOfBestCustomer(ArrayList<Double> sales,

    ArrayList<String> customers)

    {

    String summit = ” “;

    // Your composition starts here

    // Your composition ends here

    reappear summit;

    }

    generally-known static unfilled ocean(String[] args)

    {

    ArrayList<Double> worth = upstart ArrayList<Double>();

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

    Scanner in = upstart Scanner(System.in);

    // Your composition starts here

    // Your composition ends here

    Hoard summit = upstart Hoard();

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

    + summit.nameOfBestCustomer(price, designates));

    }

    }

    Thank you.

    Expert Reply

     

    import java.util.*;

    generally-known systematize Hoard
    {
    generally-known 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;
    }
    }
    reappear customers.get(max);
    }

    generally-known static ArrayList<String> designatesOfBestCustomers(ArrayList<Double> sales, ArrayList<String> customers, int summitN)
    {
    ArrayList<String> designates = upstart ArrayList<String>();
    if(topN >= sales.size())
    {
    names = upstart ArrayList<String>(customers);
    }
    else
    {
    for(int i = 0; i < summitN; 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);
    }
    }
    reappear designates;
    }

    generally-known static unfilled ocean(String[] args)
    {
    Scanner in = upstart Scanner(System.in);
    ArrayList<Double> worth = upstart ArrayList<Double>();
    ArrayList<String> designates = upstart ArrayList<String>();
    do
    {
    System.out.print(“Customer`s lapse totality: “);
    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: ” + worth.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 summit customers to diplay: “);
    int enumerate = in.nextInt();
    in.close();
    System.out.println(“The summit ” + enumerate + ” customers are: ” + designatesOfBestCustomers(price, designates, enumerate).toString());
    }
    }