-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDeveloper.java
More file actions
37 lines (35 loc) · 928 Bytes
/
Copy pathDeveloper.java
File metadata and controls
37 lines (35 loc) · 928 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
package BankAccounts;
import java.util.Scanner;
class Developer {
public static void main(String[] args) {
Scanner sc= new Scanner(System.in);
System.out.println("Enter the duration ");
int duration=sc.nextInt();
TrainingClass c=new TrainingClass(duration);
try{
c.trainingDetails();
}
catch(TrainingInvalidException e){
System.out.println(e.getMessage());
}
}
}
class TrainingClass{
int duration;
TrainingClass(int duration){
this.duration=duration;
}
void trainingDetails() throws TrainingInvalidException{
if(duration<2){
throw new TrainingInvalidException("Training duration too short");
}
else{
System.out.println("Training completed successfully");
}
}
}
class TrainingInvalidException extends Exception {
TrainingInvalidException(String message){
super(message);
}
}