#19 How to Write Program Real Life based Using else if in java ? ELSE IF in Java
package com.sudhirtheindian2.java123;
import java.util.Scanner;
public class Else_if_statement {
public static void main(String[] args) {
// How to write a program using else if in java
// It is used when we have only one if block,
// multiple else if block and at the last else block
// syntax
// if(condition1)
// {
//// statement 1
// }
// else if(condition2){
//// statement 2
// }
// else if(condition3){
////// statement 2
//// }
// else{
//// statement 3
//
// }
int marks;
System.out.println("enter your marks");
// 70 - 100 group A
// 70 - 60 group B
// 60 - 50 group C
// 40 - 50 group D
// 40> group E
Scanner scanner = new Scanner(System.in);
marks= scanner.nextInt();
if(marks>=70 && marks<=100){
System.out.println("group A");
}
else if(marks<70 && marks>60){
System.out.println("group B");
}
else if(marks>=50 && marks<=60){
System.out.println("group C");
}
else if(marks>=40&& marks<50){
System.out.println("group D");
}
else {
System.out.println("group E");
}
}
}
टिप्पणियाँ
एक टिप्पणी भेजें