Problem 1Write a program Submit CompanyGiftsjava ABC constru

Problem 1.Write a program. Submit CompanyGifts.java ABC construction wants to start sending customers gifts for their birthdays. ABC wants to create a program that allows up to 20 customers to enter their information (full names and birthdays) and also allows the manager to log in with her ID (ABC 132). When the manager logs in, she has the option to print to screen a report that shows all customers with their birthdays. If no customer information has been entered and the manager attempts to print out information, say sorry, no customers have entered any information yet. If more than 20 customers try to enter information, say sorry, no more customers. The program should be able to handle both capital and lowercase inputs. Say exit to exit the program-do not mention this on the main menu. Example run: 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 to screen Sorry, no customers have entered any information yet. Hello manager. What would you like to do? Print to screen or exit? 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):

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.

 Problem 1.Write a program. Submit CompanyGifts.java ABC construction wants to start sending customers gifts for their birthdays. ABC wants to create a program
 Problem 1.Write a program. Submit CompanyGifts.java ABC construction wants to start sending customers gifts for their birthdays. ABC wants to create a program
 Problem 1.Write a program. Submit CompanyGifts.java ABC construction wants to start sending customers gifts for their birthdays. ABC wants to create a program

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site