-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStudent_Portal.java
More file actions
37 lines (32 loc) · 1.1 KB
/
Student_Portal.java
File metadata and controls
37 lines (32 loc) · 1.1 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
import java.util.Scanner;
public class Student_Portal {
String name;
String country;
Student_Portal(){
Scanner s = new Scanner(System.in);
name = s.next();
country = s.next();
}
}
class InvalidCountryException extends Exception{
public InvalidCountryException(String exp){
super(exp);
}
}
class UserRegistration {
void registerUser(String username, String userCountry) throws InvalidCountryException {
try {
if (userCountry.equals("India")) {
System.out.println("User registration done Successfully");
} else throw new InvalidCountryException("User Outside India cannot be registered");
}
catch (InvalidCountryException e){
System.out.println(e);
}
}
public static void main(String[] args) throws InvalidCountryException {
UserRegistration ob = new UserRegistration();
Student_Portal obj = new Student_Portal();
ob.registerUser(obj.name,obj.country);
}
}