Sunday, October 8, 2017

Write a program called CheckPassFail which prints "PASS" if the int variable "mark" is more than or equal to 50; or prints "FAIL" otherwise.

/**
 * @author Sumit Srivastava
 * This class check that student is fail or pass
 */
public class CheckPassFail {
int CHECK = 50 ;        /*Check value input marks will be compared with this check value
i.e below 50 will be treated as fail otherwise pass*/
// this method returns true if student is pass otherwise fail
public boolean isPass(int number){
return number > CHECK;
}
}

public class Main {

/**
* @param args
*/
public static void main(String[] args) {
int mark;
mark = 51; //input marks of the user
System.out.println("The mark is : "+mark); //Printing input marks
CheckPassFail checkPassFail = new CheckPassFail();
if(checkPassFail.isPass(mark))
System.out.println("Your status is Pass !"); //Printing the status according to condition
else
System.out.println("your status is Fail ! "); //Printing the status according to condition
}

}

No comments:

Post a Comment