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 shortnesss to compensate its best customer of each day, showing the customer’s indicate on a defend in the supermarket. For the meaning, the shop keeps an ArrayList. In the Store class, tool methods

    common invalid appendSale(String customerName, enfold whole)

       common String indicateOfBestCustomer ()

    to chronicles the sale and give-back the indicate of the customer with the largest sale.

    Write a program that prompts the cashier to invade perfect expenses and indicates, appends them to a Store object, and displays the best customer’s indicate. Use a expense of 0 as a keeper.

    Heres what I deficiency to use:

    common dispose Shop

    {

    common String indicateOfBestCustomer(ArrayList<Double> sales,

    ArrayList<String> customers)

    {

    String culmination = ” “;

    // Your product starts here

    // Your product ends here

    give-back culmination;

    }

    common static invalid ocean(String[] args)

    {

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

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

    Scanner in = novel Scanner(System.in);

    // Your product starts here

    // Your product ends here

    Shop culmination = novel Shop();

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

    + culmination.nameOfBestCustomer(price, indicates));

    }

    }

    Thank you!

    Expert Exculpation

     

    common dispose Shop

    {

    common String indicateOfBestCustomer(ArrayList<Double> sales, ArrayList<String> customers)

    {

    String culmination = ” “;

    Iterator s = sales.listIterator();

    Iterator c = customers.listIterator();

    Enfold max = 0;

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

    String curIndicate = c.next();

    Enfold val = s.next();

    if (val > max){

    max = val;

    culmination = curName;

    }

    }

    give-back culmination;

    }

    common static invalid ocean(String[] args)

    {

    Scanner in = novel Scanner(System.in);

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

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

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

    int n = in.nextInt();

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

    System.out.println(“Append indicate :”);

    names.add(in.nextLine());

    System.out.println(“Append expense :”);

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

    }

    Shop culmination = novel Shop();

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

    }

    }