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 mitigate in the supermarket. Coercion that mind, the accumulation keeps an ArrayList. In the Accumulation assort, utensil the methods.

    notorious coid subjoinSale(String customerName, inarrest total)

       notorious String indicateOfBestCustomer()

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

    ***Please aid conclude this statute in Eclipse Java Neon and comprise the EXACT subjoined statute among it***

    ***Please rise in the spots where it says “your production starts here”***

    import java.util.*;

    /**

    * Statute coercion P7.13

    * @author

    */

    notorious assort Accumulation

    {

    notorious String indicateOfBestCustomer(ArrayList<Double> sales,

    ArrayList<String> customers)

    {

    String summit = ” “;

    // Your production starts here

    // Your production ends here

    recur summit;

    }

    notorious static null deep(String[] args)

    {

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

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

    Scanner in = odd Scanner(System.in);

    // Your production starts here

    // Your production ends here

    Accumulation summit = odd Accumulation();

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

    + summit.nameOfBestCustomer(price, indicates));

    }

    }

    Thank you.

    Expert Acceptance

     

    import java.util.*;

    notorious assort Accumulation
    {
    notorious 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;
    }
    }
    recur customers.get(max);
    }

    notorious static ArrayList<String> indicatesOfBestCustomers(ArrayList<Double> sales, ArrayList<String> customers, int summitN)
    {
    ArrayList<String> indicates = odd ArrayList<String>();
    if(topN >= sales.size())
    {
    names = odd 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);
    }
    }
    recur indicates;
    }

    notorious static null deep(String[] args)
    {
    Scanner in = odd Scanner(System.in);
    ArrayList<Double> charge = odd ArrayList<Double>();
    ArrayList<String> indicates = odd ArrayList<String>();
    do
    {
    System.out.print(“Customer`s acquisition total: “);
    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 calculate of summit customers to diplay: “);
    int calculate = in.nextInt();
    in.close();
    System.out.println(“The summit ” + calculate + ” customers are: ” + indicatesOfBestCustomers(price, indicates, calculate).toString());
    }
    }