Program that checks for internal marks & external marks, if internal marks are greater than 40 raise the exception "internal marks are exceed", if external marks are greater than 60 exception is raised and display the message "external marks exceed"
Ude.java
package ude;
import java.io.IOException;
import java.io.InputStreamReader;
import javax.security.auth.Subject;
int a;
int b;
String s;
a=internal;
b=external;
if ((a > 40) || (b > 60)) {
if (a > 40){
System.out.println("internal
marks are exceed");
}
if (b >
60) {
System.out.println("external
marks are exceed");
}
} else {
System.out.println("NO ERROR IN THE MARKS !!!!!");
}
}
}
public class Ude {
public
static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader ( new InputStreamReader(System.in));
System.out.println("Enter the Subject
name");
String subname=br.readLine();
System.out.println("Enter the internal Marks
for the subject "+subname);
String mark1=br.readLine();
int m1=Integer.parseInt(mark1);
System.out.println("Enter the external Marks for
the subject "+subname);
String mark2=br.readLine();
int m2=Integer.parseInt(mark2);
try{
throw new MyException(m1,m2);
} catch(Exception e){
}
}
}
OUTPUT:
No comments:
Post a Comment