-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStudent2.java
More file actions
60 lines (40 loc) · 860 Bytes
/
Student2.java
File metadata and controls
60 lines (40 loc) · 860 Bytes
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
public class Student2 {
String name;
int rollno ;
double marks ;
//public Student
public Student2(int r,String n,double m )
{
rollno = r ;
name = n;
marks = m;
}
void getData(int rollno,String name,double marks ) {
// this.name = name ;
this.rollno = rollno ;
this.name = name;
this.marks = marks;
}
void showData(){
System.out.print("Name:"+name+"rollno :"+rollno+" MArks : "+marks);
}
}
class StudentDemo{
public static void main(String[] args) {
int n;
System.out.printin("Enter n"+n)
Student2[] s = new Student2[n];
for(int i=0;i<n ; i++)
{
String name = Stdln.readString();
int rollno = Stdln.readInt();
double marks = Stdln.readDouble();
s[i] = new Student2(rollno,name,marks);
}
//s = new Student(101,"Amit",95.0);
for(i=0;i<n;i++)
{
StdOut.println(s[i]);
}
}
}