-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStudent_Final.java
More file actions
51 lines (51 loc) · 1.48 KB
/
Copy pathStudent_Final.java
File metadata and controls
51 lines (51 loc) · 1.48 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
import java.util.Scanner;
class Student{
int rollno;
String name;
double Gpa;
Student(int rollno,String name,double Gpa){
this.rollno=rollno;
this.name=name;
this.Gpa=Gpa;
}
public void Displayinfo(){
System.out.println("Rollno:"+this.rollno);
System.out.println("Name:"+this.name);
System.out.println("Gpa:"+this.Gpa);
}
}
public class Student_Final {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int rollno;
String name;
double Gpa;
while(true){
try {
while(true){
System.out.println("Rollno");
rollno=sc.nextInt();
if(rollno>0){
break;
}
}
sc.nextLine();
System.out.println("Enter Name:");
name=sc.nextLine();
while(true){
System.out.println("Enter Gpa:");
Gpa=sc.nextDouble();
if(Gpa>0){
break;
}
}
Student S1=new Student(rollno, name, Gpa);
S1.Displayinfo();
break;
} catch (Exception e) {
System.out.println("Error Occurred:"+e);
sc.nextLine();
}
}
}
}