-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStudent.java
More file actions
64 lines (46 loc) · 1.3 KB
/
Copy pathStudent.java
File metadata and controls
64 lines (46 loc) · 1.3 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
53
54
55
56
57
58
59
60
61
62
63
64
/*Create a Student class, with the following instance variables:
id: int
first name: String
last name: String
fees: double
and the following methods
instance methods:
getName() -> returns the firstname and lastname combined
getFees() -> returns the fees
Create three objects of the Student and print the values.
Use parameterized constructor for printing different values.
I am attaching the Employee program discussed in the class for your reference.
Thanks...
*
*
* */
package oopsconceptsprograms;
public class Student {
int id;
String first_name;
String last_name;
double fees;
public Student(int id, String first_name, String last_name, double fees) {
this.id = id;
this.first_name = first_name;
this.last_name = last_name;
this.fees = fees;
}
public void getname() {
System.out.println("Student full name is: " + first_name + " " + last_name);
}
public void getfees() {
System.out.println("Student fees is: " + fees);
}
public static void main(String[] args) {
Student stu = new Student(12, "Naveen", "Jalaraddi", 50000);
System.out.println("Student id is: " + stu.id);
stu.getname();
stu.getfees();
System.out.println();
Student stu1 = new Student(11, "Ranjan", "P", 60000);
System.out.println("Student id is: " + stu1.id);
stu1.getname();
stu1.getfees();
}
}