Question
Business P7.12 A supermarket wants to reward its best customer of each day, showing the customers name on a screen in the supermarket. For that
Business P7.12 A supermarket wants to reward its best customer of each day, showing the customers name on a screen in the supermarket. For that 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 customers name. Use a price of 0 as a sentinel.
-----
-----
-----
import java.util.*;
/**
* Code for P7.13
* @author
*/
public class Store
{
public String nameOfBestCustomer(ArrayList sales,
ArrayList customers)
{
String top = " ";
// Your work starts here
// Your work ends here
return top;
}
public static void main(String[] args)
{
ArrayList price = new ArrayList();
ArrayList names = new ArrayList();
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));
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started