-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathStudentIn.java
49 lines (34 loc) · 1008 Bytes
/
StudentIn.java
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
import java.io.*;
//import java.lang.*;
class StudentInfo{
private int rollnum;
private float marks;
char grade;
void setData(int rollnum, float marks){
this.rollnum=rollnum;
this.marks=marks;
grade = (marks>50.0f)?'P':'F';
}
void getData(){
System.out.println("My Roll No: "+rollnum);
System.out.println("My Marks: "+marks);
System.out.println("My Grade: "+grade);
}
}
class StudentIn{
public static void main(String[] args)throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter Roll Number");
String str = br.readLine();
int rollno = Integer.parseInt(str);
System.out.println("Enter Marks");
str = br.readLine();
float marks = Float.parseFloat(str);
StudentInfo s1 = new StudentInfo();
s1.setData(rollno,marks);
System.out.println("Details of Student 1");
s1.getData();
//s1.marks = 35.6f;
//System.out.println("My New Roll No: "+si.rollnum+si.marks);
}
}