Problem 1Write a program Submit CompanyGiftsjava ABC constru
Solution
/*
 * The java program CompanyGifts that prompts user
 * to enter either customer or id of manager ABC 132
 * If user enter customer then prompt name and dob
 * Then repormpt to enter customer or manger id.
 * If manager then prompt to Print then print customer
 * data to console.
 * */
 //CompanyGifts.java
 import java.util.Scanner;
 public class CompanyGifts
 {
    //Set SIZE=20
    public static final int SIZE=20;
    //create customer array of size=20
    private static Customer[] customers=new Customer[SIZE];
    //set count=0
    private static int count=0;
   
    public static void main(String[] args) {
       
       
        Scanner scanner=new Scanner(System.in);
        String mgrInput;
        boolean repeat=true;
        String choice;
        while(repeat)
        {
            choice=getChoice();
           
            if(choice.equals(\"ABC 132\"))
            {
                System.out.println(\"Hello manager. What would you like to do?\");
                System.out.println(\"Print to screen or exit\");
                mgrInput=scanner.nextLine();
               
                if(mgrInput.equals(\"Print\"))
                    print2Console(customers);
                else if(mgrInput.equals(\"exit\"))
                {
                    System.out.println(\"Bye!\");
                    System.out.println(\"***\");
                        repeat=false;
                }
            }
            else if(choice.equals(\"customer\") && count<20)
            {
                System.out.println(\"Hello customer. Please enter you name(first and last\");
                System.out.println(\"followed by your birthday(MM/DD/YYYY):\");
                String customerInput=scanner.nextLine();
               
                String[] data=customerInput.split(\" \");
               
               
               
                customers[count]
                    =new Customer(data[0], data[1], data[2]);      
                count++;      
            }
            else
                System.out.println(\"Sorry, no more customers.\");
        }
       
       
    }
   
   
    //print customers array to console
    private static void print2Console(Customer[] customers) {      
        for (int i = 0; i < count; i++) {
            System.out.println(customers[i]);
        }      
    }
  
    //prompts to enter user choice
    public static String getChoice(){
        Scanner scanner=new Scanner(System.in);
        String input;
       
        System.out.println(\"***\");
        System.out.println(\"Enter the word \\\"Customer\\\" if you are a customer\");;
        System.out.println(\"or your ID if you are the manager.\");
        input=scanner.nextLine();
       
        return input;      
    }
}
----------------------------------------------------------------------------------------------------------------------------------
 //Customer.java
 public class Customer {
   
    //private data members
    private String fName;
    private String lName;
    private String dob;
   
   
    //Constructor of class
    public Customer(String fName, String lName,
            String dob) {
        this.fName=fName;
        this.lName=lName;
        this.dob=dob;
    }
   
    //Returns the string representation of customer
    public String toString() {      
        return
        String.format(\"BIRTHDAY:%s NAME: %s %s\",dob, fName,lName);
    }
}
----------------------------------------------------------------------------------------------------------------------------------
Sample output:
***
 Enter the word \"Customer\" if you are a customer
 or your ID if you are the manager.
 ABC 132
 Hello manager. What would you like to do?
 Print to screen or exit
 Print
 No customers
 ***
 Enter the word \"Customer\" if you are a customer
 or your ID if you are the manager.
 customer
 Hello customer. Please enter you name(first and last
 followed by your birthday(MM/DD/YYYY):
 Hans Klarik 01/13/1985
 ***
 Enter the word \"Customer\" if you are a customer
 or your ID if you are the manager.
 ABC 132
 Hello manager. What would you like to do?
 Print to screen or exit
 Print
 BIRTHDAY:01/13/1985 NAME: Hans Klarik
 ***
 Enter the word \"Customer\" if you are a customer
 or your ID if you are the manager.



