Using the if-else statement, this simple program asks the user to input a number and it will display either Pass or Fail.
Passing score is 50 and above. If you input any number below 50, it displays Fail.
import java.util.Scanner;
public class PassFail {
public static void main(String[] args) {
int num;
Scanner reader = new Scanner(System.in);
System.out.println("Enter score: ");
num = reader.nextInt();
if (num>=50)
{
System.out.println("Pass!");
}
else
System.out.println("Fail!");
}
}
Passing score is 50 and above. If you input any number below 50, it displays Fail.
import java.util.Scanner;
public class PassFail {
public static void main(String[] args) {
int num;
Scanner reader = new Scanner(System.in);
System.out.println("Enter score: ");
num = reader.nextInt();
if (num>=50)
{
System.out.println("Pass!");
}
else
System.out.println("Fail!");
}
}
Here's the output:
how to write this program with oop
ReplyDeleteVery good question
Delete//Check whether the student is passed or failed and if he got passed print which rank obtained.
ReplyDeletepackage com.programs.mss;
import java.util.Scanner;
public class demo5 {
public static void main(String[] args) {
int num;
Scanner reader = new Scanner(System.in);
System.out.println("Enter score: ");
num = reader.nextInt();
if (num>90)
{
System.out.println("pass");
System.out.println("1st rank!");
}
else if (num>80)
{
System.out.println("pass");
System.out.println("2nd rank!");
}
else if (num>70)
{
System.out.println("pass");
System.out.println("3rd rank!");
}
else if (num>60)
{
System.out.println("pass");
System.out.println("4th rank!");
}
else if (num>50)
{
System.out.println("pass");
System.out.println("5th rank!");
}
else if (num<50)
{
System.out.println("Fail!");
System.out.println("Better luck next time...!!!");
}
}}
Please answer this please help!
ReplyDeleteMake a program that wi determine if the student pass or fail in subject passed on grading scheme
30% quizzes
30% written exam
40% paractical exam
Passing grade 75%
it was helpful for me thanks......
ReplyDeletehow to write the same program for multiple inputs
ReplyDeleteThanks....
ReplyDeleteif i have give the marks in any one subject below 30 how to get result fail??
ReplyDeletePlease help me to answer this question
ReplyDelete