-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStudent_Management.java
More file actions
90 lines (84 loc) · 2.69 KB
/
Copy pathStudent_Management.java
File metadata and controls
90 lines (84 loc) · 2.69 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import java.util.Scanner;
class Student{
private String name;
private int age;
private double gpa;
private int rollno;
public void setinfo(String name,int rollno,int age,double gpa ){
this.name=name;
this.rollno=rollno;
this.age=age;
this.gpa=gpa;
}
public void getinfo(){
System.out.println("Name:"+this.name);
System.out.println("Roll Number:"+this.rollno);
System.out.println("Age:"+this.age);
System.out.println("Gpa:"+this.gpa);
}
}
public class Student_Management {
public void run(){
}
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
Student[] s=new Student[2];
while (true) {
for(int i=0;i<2;i++){
String name;
int age,rollno;
double gpa;
try {
s[i]=new Student();
sc.nextLine();
System.out.println("Enter Name:");
name=sc.nextLine();
while(true){
System.out.println("Enter Rollno:");
rollno=sc.nextInt();
if(rollno<0){
System.out.println("Roll no must not be Negative");
continue;
}
if(rollno>0){
break;
}
}
while(true){
System.out.println("Enter Age");
age=sc.nextInt();
if(age<18||age>30){
System.out.println("Age Must be in between 18 to 30");
continue;
}
if(age>=18 && age<=30){
break;
}
}
while(true){System.out.println("Enter Gpa:");
gpa=sc.nextDouble();
if(gpa<0.0||gpa>4.0){
System.out.println("gpa must be in between 0.0 to 4.0");
continue;
}
if(gpa>=0.0&& gpa<=4.0){
break;
}
}
s[i].setinfo(name, rollno, age, gpa);
} catch (Exception e) {
System.out.println("Error occured"+e);
}
}
for(int i=0;i<2;i++){
System.out.println("--------Info Printing----------------");
s[i].getinfo();
}
int options;
System.out.println("1.Continue\t0.End\nEnter");
options=sc.nextInt();
if(options==0){
return;
}
}}
}