Program:
package passfailproject;
import java.util.Scanner;
public class Checkpassfail {
static Scanner sc=new Scanner(System.in);
public static void main(String[] args) {
int inputMark;
System.out.println("Enter -1 to exit the program");
System.out.println("Enter Your mark that you have got");
inputMark=sc.nextInt();
while(inputMark!=-1){
yourresult(inputMark);
System.out.println("Enter your mark again");
inputMark=sc.nextInt();
}
System.out.println("You have exited the program");
}
static public void yourresult(int mark) {
if(mark<50){
System.out.println("You have Failed");
}else{
System.out.println("You Have Passed");
}
}
}
Output:
Enter -1 to exit the program
Enter Your mark that you have got
60
You Have Passed
Enter your mark again
56
You Have Passed
Enter your mark again
49
You have Failed
Enter your mark again
76
You Have Passed
Enter your mark again
-1
You have exited the program
package passfailproject;
import java.util.Scanner;
public class Checkpassfail {
static Scanner sc=new Scanner(System.in);
public static void main(String[] args) {
int inputMark;
System.out.println("Enter -1 to exit the program");
System.out.println("Enter Your mark that you have got");
inputMark=sc.nextInt();
while(inputMark!=-1){
yourresult(inputMark);
System.out.println("Enter your mark again");
inputMark=sc.nextInt();
}
System.out.println("You have exited the program");
}
static public void yourresult(int mark) {
if(mark<50){
System.out.println("You have Failed");
}else{
System.out.println("You Have Passed");
}
}
}
Output:
Enter -1 to exit the program
Enter Your mark that you have got
60
You Have Passed
Enter your mark again
56
You Have Passed
Enter your mark again
49
You have Failed
Enter your mark again
76
You Have Passed
Enter your mark again
-1
You have exited the program
Screenshots
Program
Output
No comments:
Post a Comment