import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); Customer[] customers = new Customer[100]; // Assuming a maximum of 100 customers Complaint[] complaints = new Complaint[100]; // Assuming a maximum of 100 complaints Bill[] bills = new Bill[100]; // Assuming a maximum of 100 bills int customerCount = 0; int complaintCount = 0; int billCount = 0; boolean b = true; while (b) { System.out.println(); System.out.println("Please select an option below to perform an operation.."); System.out.println("1. Add Customer"); System.out.println("2. Delete Customer"); System.out.println("3. Update Customer"); System.out.println("4. Display Customers"); System.out.println("5. Display Customer by id"); System.out.println("6. Add Bill"); System.out.println("7. Delete Bill"); System.out.println("8. Update Bill"); System.out.println("9. Display Bill"); System.out.println("10. Register Complaint"); System.out.println("11. Search a Complaint"); System.out.println("12. Delete a Complaint"); System.out.println("0. Exit"); System.out.println("Enter your Choice: "); System.out.println(); int choice = sc.nextInt(); switch (choice) { case 1: customers[customerCount] = addCustomer(); customerCount++; break; case 2: deleteCustomer(customers, customerCount); break; case 3: updateCustomer(customers, customerCount); break; case 4: displayCustomers(customers, customerCount); break; case 5: displayCustomerDetailsByID(customers, customerCount); break; case 6: bills[billCount] = addBill(customers, customerCount); billCount++; break; case 7: deleteBill(bills, customerCount); break; case 8: updateBill(bills, customerCount); break; case 9: displayBills(bills, customers, customerCount); break; case 10: complaints[complaintCount] = registerComplaint(); complaintCount++; break; case 11: displayComplaintById(complaints, customerCount); break; case 12: deleteComplaint(complaints, customerCount); break; case 0: b = false; System.out.println("The program ends..."); break; } } sc.close(); } static class Customer { private int consumerID; private int billNumber; private String title; private String customerName; private String email; private long mobileNumber; private String userID; private String password; private String confirmPassword; public Customer(int consumerID, int billNumber, String title, String customerName, String email, long mobileNumber, String userID, String password, String confirmPassword) { this.consumerID = consumerID; this.billNumber = billNumber; this.title = title; this.customerName = customerName; this.email = email; this.mobileNumber = mobileNumber; this.userID = userID; this.password = password; this.confirmPassword = confirmPassword; } public void setConsumerID(int consumerID){this.consumerID=consumerID;} public int getConsumerID(){return consumerID;} public void setBillNumber(int billNumber){this.billNumber=billNumber;} public int getBillNumber(){return billNumber;} public void setTitle(String title){this.title=title;} public String getTitle(){return title;} public void setCustomerName(String customerName){this.customerName=customerName;} public String getCustomerName(){return customerName;} public void setEmai(String email){this.email=email;} public String getEmail(){return email;} public void setMobileNumber(long mobileNumber){this.mobileNumber=mobileNumber;} public long getMobileNumber(){return mobileNumber;} public void setUserID(String userID){this.userID=userID;} public String getUserID(){return userID;} public void setPassword(String password){this.password=password;} public String getPassword(){return password;} public void setConfirmPassword(String confirmPassword ){this.confirmPassword=confirmPassword;} public String getConfirmPassword(){return confirmPassword;} } static class Complaint { private String complaintType; private String category; private String landMark; private String customerName; private String problem; private int consumerNumber; private String address; private String mobileNumber; public Complaint(String complaintType, String category, String landMark, String customerName, String problem, int consumerNumber, String address, String mobileNumber) { this.complaintType = complaintType; this.category = category; this.landMark = landMark; this.customerName = customerName; this.problem = problem; this.consumerNumber = consumerNumber; this.address = address; this.mobileNumber = mobileNumber; } // Getters and setters // ... // Other methods // ... } static class Bill { private int consumerNumber; private double dueAmount; private double payableAmount; public Bill(int consumerNumber, double dueAmount, double payableAmount) { this.consumerNumber = consumerNumber; this.dueAmount = dueAmount; this.payableAmount = payableAmount; } public int getConsumerNumber(){ return consumerNumber ; } public double getDueAmount(){ return dueAmount; } public double getPayableAmount(){ return payableAmount; } public void setDueAmount(double newAmount){ dueAmount = newAmount; } } // Customer methods static Customer addCustomer() { Scanner sc = new Scanner(System.in); System.out.println("Enter the below details to register.."); System.out.print("Enter Consumer ID : "); int cid = sc.nextInt(); System.out.print("Enter Bill Number : "); int bnum = sc.nextInt(); System.out.print("Enter Title : "); sc.nextLine(); String title = sc.next(); System.out.print("Enter Customer Name : "); String cname = sc.next(); System.out.print("Enter Email : "); String email = sc.next(); System.out.print("Enter Mobile Number : "); long mnum = sc.nextLong(); System.out.print("Enter User ID : "); sc.nextLine(); String uid = sc.next(); System.out.print("Enter Password : "); String psswd = sc.next(); System.out.print("Enter Confirmed Password : "); String cpas = sc.next(); return new Customer(cid, bnum, title, cname, email, mnum, uid, psswd, cpas); } static void deleteCustomer(Customer[] customers, int count) { Scanner sc = new Scanner(System.in); System.out.print("Enter consumer id : "); int rid = sc.nextInt(); int index = findCustomerIndexById(customers, count, rid); if (index != -1) { for (int i = index; i < count - 1; i++) { customers[i] = customers[i + 1]; } count--; System.out.println("Customer removed successfully....."); } else { System.out.println("No data found.."); } } static void updateCustomer(Customer[] customers, int count) { Scanner sc = new Scanner(System.in); System.out.println("Please enter your registered email and customer id."); System.out.println("Enter your mail address:"); String email = sc.next(); System.out.println("Enter your customer id:"); int id = sc.nextInt(); int index = findCustomerIndexById(customers, count, id); if (index != -1) { System.out.println("Enter your updated email: "); String uemail = sc.next(); customers[index].setEmail(uemail); System.out.println("Your email updated successfully... :)"); } else { System.out.println("No data found in the database.. :("); } } static void displayCustomers(Customer[] customers, int count) { if (count > 0) { for (int i = 0; i < count; i++) { System.out.println("Customer " + i + " details are ..."); System.out.println("Consumer ID: " + customers[i].getConsumerID()); System.out.println("Bill Number: " + customers[i].getBillNumber()); System.out.println("Title: " + customers[i].getTitle()); System.out.println("Customer Name: " + customers[i].getCustomerName()); System.out.println("Email: " + customers[i].getEmail()); System.out.println("Mobile Number: " + customers[i].getMobileNumber()); System.out.println("User ID: " + customers[i].getUserID()); } } else { System.out.println("No data to show"); } } static void displayCustomerDetailsByID(Customer[] customers, int count) { Scanner sc = new Scanner(System.in); System.out.println("Enter the below details to display specific customer."); System.out.print("Enter consumer id : "); int id = sc.nextInt(); int index = findCustomerIndexById(customers, count, id); if (index != -1) { System.out.println("Consumer ID | CustomerName | Mobile Number | Email "); System.out.println(customers[index].getConsumerID() + " | " + customers[index].getCustomerName() + " | " + customers[index].getMobileNumber() + " | " + customers[index].getEmail()); } else { System.out.println("No data found in the database.."); } } static int findCustomerIndexById(Customer[] customers, int count, int id) { for (int i = 0; i < count; i++) { if (customers[i].getConsumerID() == id) { return i; } } return -1; // Not found } // Bill methods static Bill addBill(Customer[] customers, int count) { Scanner sc = new Scanner(System.in); System.out.println("Enter Consumer number"); int consumerNumber = sc.nextInt(); System.out.println("Enter DueAmount"); double dueAmount = sc.nextDouble(); System.out.println("Enter payable Amount"); double payableAmount = sc.nextDouble(); int index = findCustomerIndexById(customers, count, consumerNumber); if (index != -1) { System.out.println("Bill details added successfully"); return new Bill(consumerNumber, dueAmount, payableAmount); } else { System.out.println("Customer not found. Bill details not added."); return null; } } static void deleteBill(Bill[] bills, int count) { Scanner sc = new Scanner(System.in); System.out.print("Enter Consumer Number to delete the Details: "); int consumerNumber = sc.nextInt(); int index = findBillIndexByConsumerNumber(bills, count, consumerNumber); if (index != -1) { for (int i = index; i < count - 1; i++) { bills[i] = bills[i + 1]; } count--; System.out.println("Bill details are deleted"); } else { System.out.println("Bill not found with the given Consumer Number"); } } static void updateBill(Bill[] bills, int count) { Scanner sc = new Scanner(System.in); System.out.print("Enter Consumer Number to Update the Details: "); int consumerNumber = sc.nextInt(); int index = findBillIndexByConsumerNumber(bills, count, consumerNumber); if (index != -1) { System.out.print("Enter new amount: "); double newAmount = sc.nextDouble(); bills[index].setDueAmount(newAmount); System.out.println("Bill details are updated successfully"); } else { System.out.println("Bill not found with the given Consumer Number"); } } static void displayBills(Bill[] bills, Customer[] customers, int customerCount) { Scanner sc = new Scanner(System.in); System.out.print("Enter Consumer ID to get Data: "); int consumerId = sc.nextInt(); String name = ""; int index = findCustomerIndexById(customers, customerCount, consumerId); if (index != -1) { name = customers[index].getCustomerName(); } int billIndex = findBillIndexByConsumerNumber(bills, customerCount, consumerId); if (billIndex != -1) { System.out.println("Consumer ID | CustomerName | Due Amount | Payable Amount"); System.out.println(bills[billIndex].getConsumerNumber() + " | " + name + " | " + bills[billIndex].getDueAmount() + " | " + bills[billIndex].getPayableAmount()); } else { System.out.println("No bill found for the given Consumer ID"); } } static int findBillIndexByConsumerNumber(Bill[] bills, int count, int consumerNumber) { for (int i = 0; i < count; i++) { if (bills[i].getConsumerNumber() == consumerNumber) { return i; } } return -1; // Not found } // Complaint methods static Complaint registerComplaint() { Scanner sc = new Scanner(System.in); System.out.println("Enter Complaint Type:"); String complaintType = sc.nextLine(); System.out.println("Enter Category:"); String category = sc.nextLine(); System.out.println("Enter LandMark:"); String landMark = sc.nextLine(); System.out.println("Enter Customer Name:"); String customerName = sc.nextLine(); System.out.println("Enter Problem:"); String problem = sc.nextLine(); System.out.println("Enter Consumer Number:"); int consumerNumber = sc.nextInt(); System.out.println("Enter Address:"); sc.nextLine(); String address = sc.nextLine(); System.out.println("Enter Mobile Number (10 digits):"); String mobileNumber = sc.nextLine(); return new Complaint(complaintType, category, landMark, customerName, problem, consumerNumber, address, mobileNumber); } static void deleteComplaint(Complaint[] complaints, int count) { Scanner sc = new Scanner(System.in); System.out.print("Enter Consumer Number to delete complaint: "); int consumerNumber = sc.nextInt(); int index = findComplaintIndexByConsumerNumber(complaints, count, consumerNumber); if (index != -1) { for (int i = index; i < count - 1; i++) { complaints[i] = complaints[i + 1]; } count--; System.out.println("Complaint details are deleted."); } else { System.out.println("Consumer not found. No complaint details deleted."); } } static void displayComplaintById(Complaint[] complaints, int customerCount) { System.out.print("Enter the Consumer Id: "); Scanner sc = new Scanner(System.in); int inp = sc.nextInt(); int index = findComplaintIndexByConsumerNumber(complaints, customerCount, inp); if (index != -1) { System.out.println("Consumer ID | CustomerName | Complaint Type | Category | Problem Description | Mobile"); System.out.println(complaints[index].getConsumerNumber() + " | " + complaints[index].getCustomerName() + " | " + complaints[index].getComplaintType() + " | " + complaints[index].getCategory() + " | " + complaints[index].getProblem() + " | " + complaints[index].getMobileNumber()); } else { System.out.println("No data found for the given Consumer ID."); } } static int findComplaintIndexByConsumerNumber(Complaint[] complaints, int count, int consumerNumber) { for (int i = 0; i < count; i++) { if (complaints[i].getConsumerNumber() == consumerNumber) { return i; } } return -1; // Not found } }