Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a class called Customer (5 pts) Implement a class to maintain information

ID: 3854660 • Letter: C

Question

Create a class called Customer (5 pts)

Implement a class to maintain information about a customer including: gender (boolean), first name, last name, birth date (day, month, year), address, city, state, zip code, credit card brand, and current balance (double).

Provide appropriate names and data types for each of the instance variables. public Customer (String info) - a constructor that initializes all of the instance variables to appropriate values. See information below about parsing Strings into smaller pieces.

female, Amy, Zu, 4/9/1960, 54 Elm St, Any City, NC, 27834, Visa, 15339.19

public boolean isFemale() – return true if female and false if male. provide get methods for each of the instance variables (except gender).

public String getFirst() public String getLast() public String getAddress() public String getCity() public String getState() public String getCreditCard() public int getDay() public int getMonth() public int getYear()

public double getBalance() provide matching set methods for each instance variable. Although the set methods are not used for this project it is good practice to provide them for most classes. public String toString( ) - return a formatted mailing label (a single String with embedded newlines) . For example, John Smith 123 Elm St. Anytown, ST 12345 public static void main(String args[]) – thoroughly test each of the methods in this class.

Explanation / Answer

Note : Could you please check the output .If you required any changes Just intimate.I will modify it.Thank You.

______________________

Customer.java

public class Customer {

//Declaring variables

private String gender;

private String firstame;

private String lastname;

private String birthdate;

private int day;

private int month;

private int year;

private String address;

private String city;

private String state;

private int zipcode;

private String creditcardbrand;

private double current_balance;

String str[]=new String[3];

//parameterized constructor

public Customer(String gender, String firstame, String lastname,

String birthdate, String address, String city, String state,

int zipcode, String creditcardbrand, double current_balance) {

super();

this.gender = gender;

this.firstame = firstame;

this.lastname = lastname;

this.birthdate = birthdate;

this.address = address;

this.city = city;

this.state = state;

this.zipcode = zipcode;

this.creditcardbrand = creditcardbrand;

this.current_balance = current_balance;

str=birthdate.split("/");

}

//Setters and getters

public boolean isGender() {

if(gender.equalsIgnoreCase("male"))

return false;

else

return true;

}

public String getFirstame() {

return firstame;

}

public String getLastname() {

return lastname;

}

public int getDay() {

return Integer.parseInt(str[1]);

}

public int getMonth() {

return Integer.parseInt(str[0]);

}

public int getYear() {

return Integer.parseInt(str[2]);

}

public String getAddress() {

return address;

}

public String getCity() {

return city;

}

public String getState() {

return state;

}

public int getZipcode() {

return zipcode;

}

public String getCreditcardbrand() {

return creditcardbrand;

}

public double getCurrent_balance() {

return current_balance;

}

//toString method is used to display the contents of an object inside it

@Override

public String toString() {

return ":: Customer Info :: Gender=" + isGender() + ", Firstame=" + firstame

+ ", Lastname=" + lastname + ", Day=" + getDay() + ", Month="

+getMonth() + ", Year=" + getYear() + ", Address=" + address + ", City="

+ city + ", State=" + state + ", Zipcode=" + zipcode

+ ", Creditcardbrand=" + creditcardbrand + ", Current_balance="

+ current_balance;

}

}

_______________________

Test.java

public class Test {

public static void main(String[] args) {

//Creating an Customer class object by passing inputs as arguments

Customer c=new Customer("female","Amy","Zu","4/9/1960","54 Elm St","Any City","NC",27834,"Visa",15339.19);

  

//calling the toString() method on the Customer class object

System.out.println(c.toString());

}

}

____________________

Output:

:: Customer Info ::
Gender=true,
Firstame=Amy,
Lastname=Zu,
Day=9,
Month=4,
Year=1960,
Address=54 Elm St,
City=Any City,
State=NC,
Zipcode=27834,
Creditcardbrand=Visa,
Current_balance=15339.19

--------------------Thank You

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote