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 indicate on a ward in the supermarket. Control that intention, the provision keeps an ArrayList. In the Provision tabulate, instrument the methods.

    general coid subjoinSale(String customerName, envelop aggregate)

       general String indicateOfBestCustomer()

    to chronicles the sale and repay the indicate of the customer with the largest sale. Write a program that prompts the chasier to invade every charges and indicates, subjoins them to a Provision obect, and displays the best customer’s indicate. Use the charge of a 0 as a watch.

    ***Please succor conclude this sequence in Eclipse Java Neon and involve the EXACT controlthcoming sequence amid it***

    ***Please increase in the spots where it says “your employment starts here”***

    import java.util.*;

    /**

    * Sequence control P7.13

    * @author

    */

    general tabulate Provision

    {

    general String indicateOfBestCustomer(ArrayList<Double> sales,

    ArrayList<String> customers)

    {

    String culmination = ” “;

    // Your employment starts here

    // Your employment ends here

    repay culmination;

    }

    general static empty deep(String[] args)

    {

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

    ArrayList<String> indicates = novel ArrayList<String>();

    Scanner in = novel Scanner(System.in);

    // Your employment starts here

    // Your employment ends here

    Provision culmination = novel Provision();

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

    + culmination.nameOfBestCustomer(price, indicates));

    }

    }

    Thank you.

    Expert Acceptance

     

    import java.util.*;

    general tabulate Provision
    {
    general static String indicateOfBestCustomer(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;
    }
    }
    repay customers.get(max);
    }

    general static ArrayList<String> indicatesOfBestCustomers(ArrayList<Double> sales, ArrayList<String> customers, int culminationN)
    {
    ArrayList<String> indicates = novel ArrayList<String>();
    if(topN >= sales.size())
    {
    names = novel ArrayList<String>(customers);
    }
    else
    {
    for(int i = 0; i < culminationN; 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);
    }
    }
    repay indicates;
    }

    general static empty deep(String[] args)
    {
    Scanner in = novel Scanner(System.in);
    ArrayList<Double> charge = novel ArrayList<Double>();
    ArrayList<String> indicates = novel ArrayList<String>();
    do
    {
    System.out.print(“Customer`s donation aggregate: “);
    price.add(in.nextDouble());
    if(price.get(price.size() – 1) != 0)
    {
    System.out.println(“nCustomer`s indicate: “);
    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: ” + indicates.toString());
    System.out.println(“Best customer of the day is ” + indicateOfBestCustomer(price, indicates));
    System.out.println(“Invade the enumerate of culmination customers to diplay: “);
    int enumerate = in.nextInt();
    in.close();
    System.out.println(“The culmination ” + enumerate + ” customers are: ” + indicatesOfBestCustomers(price, indicates, enumerate).toString());
    }
    }