-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCustomer.java
More file actions
53 lines (41 loc) · 1.28 KB
/
Customer.java
File metadata and controls
53 lines (41 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*Create a Customer class , with data members (all private : tight encapsulation) name(String),
email(String),age(int).Supply a parameterized constructor to accept all details from user.
Supply an argument less constructor to init default name to "Riya" , email to "riya@gmail.com",age=25.
Write a method displayCustomer to display customer details.*/
import java.util.Scanner;
public class Customer {
private String name;
private String email;
private int age;
Scanner input = new Scanner(System.in);
public Customer(String name,String email,int age) {
this.name = name;
this.email = email;
this.age = age;
}
public Customer() {
this.name = "Riya";
this.email = "riya@gmail.com";
this.age = 25;
}
public void acceptCustomer() {
System.out.print("Enter Name : ");
this.name = input.nextLine();
System.out.print("Enter Email: ");
this.email = input.next();
System.out.print("Enter Age : ");
this.age= input.nextInt();
input.close();
}
public void displayCustomer() {
System.out.println("Name :"+this.name);
System.out.println("Email :"+this.email);
System.out.println("Age :"+this.age);
}
public static void main(String[] args) {
Customer C1 = new Customer();
C1.acceptCustomer();
System.out.println();
C1.displayCustomer();
}
}