Create a class called Customer that includes three pieces of information as instance variables - a firstname (type string), a last name (type string) and a credit limit (double) Your class should have a constructor that initializes the three values. a. Provide a customer that initializes these three instance variables. Validate credit limit; it must be greater than 0.0. b. Provide set and get methods for each instance variable. Validate credit limit; it must be greater than 0.0. Write a test application named CustomerTest that demonstrates class Customer's capabilities. a. Create two customer objects. b. Display each customer's first name, last nam, and credit limit. For doubles, displays two integers after the decimal points. c. Then, raise each customer's credit limit by 20%. b. Display each customer's first name, last name, and credit limit again. For doubles, display two integers after the decimal point.
`Hey,
Note: Brother in case of any queries, just comment in box I would be very happy to assist all your queries
class Customer {
private String firstName;
private String lastName;
private double creditLimit;
public Customer () {
this.firstName = null;
this.lastName = null;
this.creditLimit = 0;
}
public Customer (String firstName, String lastName, double
creditLimit) {
this.firstName = firstName;
this.lastName = lastName;
this.creditLimit = creditLimit;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public double getCreditLimit() {
return creditLimit;
}
public void setCreditLimit(double creditLimit) {
if(creditLimit > 0)
this.creditLimit = creditLimit;
}
}
public class CustomerTest {
public static void main(String args[]) {
Customer cust1 = new Customer ("cust", "1", 10000);
Customer cust2 = new Customer ("cust", "2", 20000);
System.out.println("Yearly credit limit ");
System.out.println(cust1.getFirstName()+" "+cust1.getLastName()+"
---- "+String.format("%.2f",cust1.getCreditLimit()) );
System.out.println(cust2.getFirstName()+" "+cust2.getLastName()+"
---- "+String.format("%.2f",cust2.getCreditLimit()) );
//increase limit of each by 20%
cust1.setCreditLimit(cust1.getCreditLimit() * (1.0 +
20.0/100.0));
cust2.setCreditLimit(cust2.getCreditLimit() * (1.0 +
20.0/100.0));
System.out.println("Yearly credit limit ");
System.out.println(cust1.getFirstName()+" "+cust1.getLastName()+"
---- "+String.format("%.2f",cust1.getCreditLimit()) );
System.out.println(cust2.getFirstName()+" "+cust2.getLastName()+"
---- "+String.format("%.2f",cust2.getCreditLimit()));
}
}
Kindly revert for any queries
Thanks.
Create a class called Customer that includes three pieces of information as instance variables - a...
Create a class called Employee that includes three instance variables—a first name, a last name, and a monthly salary. Code the default (no-args, empty) constructor. Provide a set and a get method for each instance variable. If the monthly salary is not positive, do not set its value.
Start a new project in NetBeans that defines a class Person with the following: Instance variables firstName (type String), middleInitial (type char) and lastName (type String) (1) A no-parameter constructor with a call to the this constructor; and (2) a constructor with String, char, String parameters (assign the parameters directly to the instance variables in this constructor--see info regarding the elimination of set methods below) Accessor (get) methods for all three instance variables (no set methods are required which makes...
In a project named 'DogApplication', create a class called 'Dog' 1. declare two instance variables in 'Dog' : name (String type) age (int type) 2. declare the constructor for the 'Dog' class that takes two input parameters and uses these input parameters to initialize the instance variables 3. create another class called 'Driver' and inside the main method, declare two variables of type 'Dog' and call them 'myDog' and 'yourDog', then assign two variables to two instance of 'Dog' with...
In one file create an Employee class as per the following specifications: three private instance variables: name (String), startingSalary (int), yearlyIncrement (int) a single constructor with three arguments: the name, the starting salary, and the yearly increment. In the constructor, initialize the instance variables with the provided values. get and set methods for each of the instance variables. A computation method, computeCurrentSalary, that takes the number of years in service as its argument. The method returns the current salary using...
E2a: Create a class called Employee that includes three
pieces of information as data members---a first name (char array),
last name (char array) and a monthly salary (integer). Your class
should have a constructor that initializes the three data members.
If the monthly salary is not positive, set it to 0. Write a test
program that demonstrates class Employee’s capabilities. Create two
Employee objects and display each object’s yearly salary. Then give
each Employee a 10 percent raise and display...
dateInformation class. visual basic. Crate a class called DateInformation that includes three pieces of information as intense variable- a month(type Integer), a day(type Integer) and year (type Integer). Your class should provide properties that enables a client of the class to get and set the month, day, year values.The set acessor should perform validation and throw exception for invalid values. You class should have a constructor that initializes the three instances variables and uses the class's property to set each...
In JAVA
1. Create a class called Rectangle that has integer data members named - length and width. Your class should have a default constructor (no arg constructor) Rectangle() that initializes the two instance variables of the object Rect1. The second overloading constructor should initializes the value of the second object Rect2. The class should have a member function named GetWidth() and GetLength() that display rectangle's length and width. OUTPUT: Rectl width: 5 Rectl length: 10 Enter a width :...
Create a class Circle with one instance variable of type double called radius. Then define an appropriate constructor that takes an initial value for the radius, get and set methods for the radius, and methods getArea and getPerimeter. Create a class RightTriangle with three instance variables of type double called base, height, and hypotenuse. Then define an appropriate constructor that takes initial values for the base and height and calculates the hypotenuse, a single set method which takes new values...
You may not add any instance variables to any class, though you may create local variables inside of a method to accomplish its task. No other methods should be created other than the ones listed here. Step 1 Develop the following class: Class Name: CollegeDegree Access Modifier: public Instance variables Name: major Access modifier: private Data type: String Name: numberOfCourses Access modifier: private Data type: int Name: courseNameArray Access modifier: private Data type: String [ ] Name: courseCreditArray Access...
You may not add any instance variables to any class, though you may create local variables inside of a method to accomplish its task. No other methods should be created other than the ones listed here. (I need step 2 please.) Step 1 Develop the following class: Class Name: CollegeDegree Access Modifier: public Instance variables Name: major Access modifier: private Data type: String Name: numberOfCourses Access modifier: private Data type: int Name: courseNameArray Access modifier: private Data type: String [...