Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- interface Exam{
- boolean pass(int marks);
- }
- interface Classify{
- String division(int average);
- }
- class Result implements Exam, Classify{
- public boolean pass(int marks){
- if(marks > 40) return true;
- else return false;
- }
- public String division(int average){
- if(average < 40) return "Third";
- else if (average > 40 && average < 60) return "Second";
- else return "First";
- }
- public static void main(String[] args){
- int DSA, OOPM, DBMS;
- Scanner sc = new Scanner(System.in);
- Result r = new Result();
- System.out.print("Enter marks for DSA on 100: ");
- DSA = sc.nextInt();
- if(r.pass(DSA)) System.out.println("Passed in DSA.");
- else System.out.println("Failed in DSA.");
- System.out.print("Enter the score for OOPM on 100: ");
- OOPM = sc.nextInt();
- if(r.pass(OOPM)) System.out.println("Passed in OOPM.");
- else System.out.println("Failed in OOPM.");
- System.out.print("Enter the score for DBMS on 100: ");
- DBMS = sc.nextInt();
- if(r.pass(DBMS)) System.out.println("Passed in DBMS.");
- else System.out.println("Failed in DBMS.");
- System.out.println("The class is "+r.division((DSA+OOPM+DBMS)/3));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement