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 scantinesss to pay its best customer of each day, showing the customer’s spectry on a protect in the supermarket. For the object, the stock keeps an ArrayList. In the Store class, instrument methods

    generally-known unfilled supplementSale(String customerName, double totality)

       generally-known String spectryOfBestCustomer ()

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

    Write a program that prompts the banish to invade integral values and spectrys, supplements them to a Store object, and displays the best customer’s spectry. Use a value of 0 as a patrol.

    Heres what I scantiness to use:

    generally-known systematize Stock

    {

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

    ArrayList<String> customers)

    {

    String summit = ” “;

    // Your product starts here

    // Your product ends here

    recompense summit;

    }

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

    {

    ArrayList<Double> value = strange ArrayList<Double>();

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

    Scanner in = strange Scanner(System.in);

    // Your product starts here

    // Your product ends here

    Stock summit = strange Stock();

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

    + summit.nameOfBestCustomer(price, spectrys));

    }

    }

    Thank you!

    Expert Response

     

    generally-known systematize Stock

    {

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

    {

    String summit = ” “;

    Iterator s = sales.listIterator();

    Iterator c = customers.listIterator();

    Double max = 0;

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

    String curSpectry = c.next();

    Double val = s.next();

    if (val > max){

    max = val;

    summit = curName;

    }

    }

    recompense summit;

    }

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

    {

    Scanner in = strange Scanner(System.in);

    ArrayList<Double> value = strange ArrayList<Double>();

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

    System.out.println(“How numerous customer grounds you scantiness to invade ?”);

    int n = in.nextInt();

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

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

    names.add(in.nextLine());

    System.out.println(“Supplement value :”);

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

    }

    Stock summit = strange Stock();

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

    }

    }