Answer :
Java is a programming language and computing platform that is widely used for building a variety of applications.
How to write the given code in java?
Here is an example of a Java program that provides the functionality described in the question:
import java.util.Scanner;
import java.util.ArrayList;
public class CustomerTracker {
static ArrayList<Customer> customers = new ArrayList<>();
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int option = 0;
while (option != 6) {
System.out.println("Menu:");
System.out.println("1. Add multiple new customers");
System.out.println("2. Add single new customer");
System.out.println("3. Display all customers");
System.out.println("4. Retrieve specific customer's data");
System.out.println("5. Retrieve customers with total sales based on the range");
System.out.println("6. Exit");
System.out.print("Enter option: ");
option = sc.nextInt();
sc.nextLine();
switch (option) {
case 1:
addMultipleCustomers();
break;
case 2:
addSingleCustomer();
break;
case 3:
displayAllCustomers();
break;
case 4:
retrieveCustomerData();
break;
case 5:
retrieveCustomersInRange();
break;
case 6:
break;
default:
System.out.println("Invalid option. Please try again.");
}
}
}
public static void addMultipleCustomers() {
Scanner sc = new Scanner(System.in);
System.out.print("Enter number of customers to add: ");
int numCustomers = sc.nextInt();
sc.nextLine();
for (int i = 0; i < numCustomers; i++) {
System.out.print("Enter customer name: ");
String name = sc.nextLine();
System.out.print("Enter customer id (5 digits): ");
int id = sc.nextInt();
System.out.print("Enter total sales: ");
double sales = sc.nextDouble();
sc.nextLine();
Customer c = new Customer(name, id, sales);
customers.add(c);
}
}
public static void addSingleCustomer() {
Scanner sc = new Scanner(System.in);
System.out.print("Enter customer name: ");
String name = sc.nextLine();
System.out.print("Enter customer id (5 digits): ");
int id = sc.nextInt();
System.out.print("Enter total sales: ");
double sales = sc.nextDouble();
sc.nextLine();
Customer c = new Customer(name, id, sales);
customers.add(c);
}
public static void displayAllCustomers() {
for (Customer c : customers) {
System.out.println(c.getName() + " " + c.getId() + " " + c.getSales());
}
}
public static void retrieveCustomerData() {
Scanner sc = new Scanner(System.in);
System
To Know More About Java, Check Out
https://brainly.com/question/13261090
#SPJ4