Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Executer
- {
- public static void main(String[] args)
- {
- int ctr=0;
- Customer c[]=new Customer[10];
- for(;;)
- {
- int choice;
- System.out.println("Welcome");
- System.out.println("Current Customers Count :" +ctr);
- menu();
- Scanner scanner=new Scanner(System.in);
- choice=Integer.parseInt(scanner.nextLine());
- if(choice==1)
- {
- c[ctr]=new Customer();
- System.out.println("Enter FirstName");
- c[ctr].setFirstName(scanner.nextLine());
- System.out.println("Enter LastName");
- c[ctr].setLastName(scanner.nextLine());
- System.out.println("Enter CustomerID");
- c[ctr].setCustomerID(scanner.nextLine());
- ctr++;
- }
- else if(choice==2)
- {
- String search;
- System.out.println("Enter CustomerID");
- search=scanner.nextLine();
- for(int k=0;k<ctr;k++)
- {
- if(search.equals(c[k].getCustomerID()))
- {
- System.out.println("Found");
- System.out.println("Enter New FirstName");
- c[k].setFirstName(scanner.nextLine());
- System.out.println("Enter New LastName");
- c[k].setLastName(scanner.nextLine());
- System.out.println("Updated");
- break;
- }
- }
- }
- else if(choice==3)
- {
- String search;
- System.out.println("Enter CustomerID");
- search=scanner.nextLine();
- for(int k=0;k<ctr;k++)
- {
- if(search.equals(c[k].getCustomerID()))
- {
- System.out.println("Found");
- System.out.println(c[k].getFirstName()+","+c[k].getLastName()+","+c[k].getCustomerID());
- break;
- }
- }
- }
- else if(choice==4)
- {
- for(int k=0;k<ctr;k++)
- {
- System.out.println(c[k].getFirstName()+","+c[k].getLastName()+c[k].getCustomerID());
- }
- }
- }
- }
- public static void menu()
- {
- System.out.println("Welcome");
- System.out.println("1. Add Customer");
- System.out.println("2. Edit Customer");
- System.out.println("3. Search Customer");
- System.out.println("4. List Customers");
- System.out.println("Enter your choice");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement