I need to write a java program and i am having the worst time. the application w
ID: 3545430 • Letter: I
Question
I need to write a java program and i am having the worst time. the application will be to designed, store, and procces data about buisness customer and employees. The application promts the user to enter a customer or an employee. If the user selects a customer, the application asks for the name, email, and customer number. If the user selects employee, the application asks for name, email, and social security number. When the user finishes entereing data for a customer or employee, the application displays the data that the user entered.
Explanation / Answer
package chegg;
import java.util.Scanner;
public class CollectDate {
static Employee employee = new Employee();
static Customer customer = new Customer();
static Scanner input = new Scanner(System.in);
static String options = "Enter your choice : a.Employee b.Customer q.quit";
public static void main(String args[]) {
String option = readOptions();
while(true){
if (option.equalsIgnoreCase("a")) {
System.out.println("Enter Employee Name : ");
employee.setName(input.next());
System.out.println("Enter Employee e-mail : ");
employee.setEmail(input.next());
System.out.println("Enter Social Security Number : ");
employee.setSocialSecurityNumber(input.next());
System.out.println(employee);
option = readOptions();
} else if (option.equalsIgnoreCase("b")) {
System.out.println("Enter Customer Name : ");
customer.setName(input.next());
System.out.println("Enter Customer e-mail : ");
customer.setEmail(input.next());
System.out.println("Enter Customer Number : ");
customer.setCustomerNumber(input.next());
System.out.println(customer);
option = readOptions();
}else if (option.equalsIgnoreCase("q")) {
System.out.println("Goodbye");
System.exit(1);
} else {
System.out.println("Invalid Input!");
option = readOptions();
}
}
}
public static String readOptions(){
Scanner input = new Scanner(System.in);
System.out.println(options);
return input.next();
}
}
class Customer {
private String name, email, customerNumber;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getCustomerNumber() {
return customerNumber;
}
public void setCustomerNumber(String customerNumber) {
this.customerNumber = customerNumber;
}
public String toString() {
return "[" + getName() + "," + getEmail() + "." + getCustomerNumber()
+ "]";
}
}
class Employee {
private String name, email, socialSecurityNumber;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getSocialSecurityNumber() {
return socialSecurityNumber;
}
public void setSocialSecurityNumber(String socialSecurityNumber) {
this.socialSecurityNumber = socialSecurityNumber;
}
public String toString() {
return "[" + getName() + "," + getEmail() + "."
+ getSocialSecurityNumber() + "]";
}
}