Write if-else statement that outputs
Student must achieve at least 40 in the exam grade and 70% in the attendance in order to pass the module (print out “You pass the module!”). If the student fails the attendance only, the student needs to take classes to make up the attendance (print out ”Please take classes to make up your attendance.”) . If the student fails the exam grade only, the student is eligible to apply re-exam (print out “You are eligible for re-exam”). If the student fails both the exam and the attendance, the student needs to retake the whole module (print out Please retake the module”).
The variables attendance is of type double, and grade is of type int.
if (______________________ ) {
_______________________________________________________
}
elseif (___________________) {
______________________________________________________
}
elseif (___________________) {
______________________________________________________
}
else {
______________________________________________________
}
import java.util.Scanner;
public class App {
/**
* The start point of the program
*
* @param args
*
*/
public static void main(String[] args) {
Scanner keyBoard = new Scanner(System.in);
System.out.print("Enter the exam grade: ");
int grade = keyBoard.nextInt();
System.out.print("Enter the attendance: ");
double attendance = keyBoard.nextDouble();
if (grade >= 40 && attendance >= 70) {
System.out.println("You pass the module!");
} else if (grade >= 40 && attendance < 70) {
System.out.println("Please take classes to make up your attendance.");
} else if (grade < 40 && attendance >= 70) {
System.out.println("You are eligible for re-exam");
} else {
System.out.println("Please retake the module");
}
keyBoard.close();
}
}
Comments
Leave a comment