Homework Solution: Eclipse Java Neon…

    Eclipse Java Neon A supermarket wants to reward its best customer of each day, showing the customer's name on a screen in the supermarket. For the purpose, the store keeps an ArrayList. In the Store class, implement methods public void 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 cashier to enter all prices and names, adds them to a Store object, and displays the best customer's name. Use a price of 0 as a sentinel. Heres what I need to use: 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

     
    public class Store {

    Eclipse Java Neon

    A supermarket insufficiencys to compensate its best customer of each day, showing the customer’s spectry on a mitigate in the supermarket. For the object, the garner keeps an ArrayList. In the Store class, instrument methods

    generally-known invalid subjoinSale(String customerName, envelop total)

       generally-known String spectryOfBestCustomer ()

    to archives the sale and repay the spectry of the customer with the largest sale.

    Write a program that prompts the cashier to invade complete worths and spectrys, subjoins them to a Store object, and displays the best customer’s spectry. Use a worth of 0 as a sentry.

    Heres what I insufficiency to use:

    generally-known collocate Garner

    {

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

    ArrayList<String> customers)

    {

    String culmination = ” “;

    // Your product starts here

    // Your product ends here

    repay culmination;

    }

    generally-known static invalid deep(String[] args)

    {

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

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

    Scanner in = odd Scanner(System.in);

    // Your product starts here

    // Your product ends here

    Garner culmination = odd Garner();

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

    + culmination.nameOfBestCustomer(price, spectrys));

    }

    }

    Thank you!

    Expert Tally

     

    generally-known collocate Garner

    {

    generally-known String spectryOfBestCustomer(ArrayList<Double> sales, ArrayList<String> customers)

    {

    String culmination = ” “;

    Iterator s = sales.listIterator();

    Iterator c = customers.listIterator();

    Envelop max = 0;

    while (c.hasNext() && s.hasNext()) {

    String curSpectry = c.next();

    Envelop val = s.next();

    if (val > max){

    max = val;

    culmination = curName;

    }

    }

    repay culmination;

    }

    generally-known static invalid deep(String[] args)

    {

    Scanner in = odd Scanner(System.in);

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

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

    System.out.println(“How divers customer postulates you insufficiency to invade ?”);

    int n = in.nextInt();

    for (int i = 0; i < n; i++) {

    System.out.println(“Subjoin spectry :”);

    names.add(in.nextLine());

    System.out.println(“Subjoin worth :”);

    price.add(Double.parseDouble(in.nextLine()));

    }

    Garner culmination = odd Garner();

    System.out.println(“Best customer’s spectry ” + culmination.nameOfBestCustomer(price, spectrys));

    }

    }