Answer:
import java.util.Scanner;
public class Main
{
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int classesHeld, classesAttended;
double percentage;
System.out.print("Enter number of classes held: ");
classesHeld = input.nextInt();
System.out.print("Enter number of classes attended: ");
classesAttended = input.nextInt();
percentage = (double) classesAttended / classesHeld;
if(percentage < 0.75)
System.out.println("You are not allowed to sit in exam");
else
System.out.println("You are allowed to sit in exam");
}
}
Step-by-step explanation:
Import the Scanner to be able to get input from the user
Create a Scanner object to get input
Declare the variables
Ask the user to enter classesHeld and classesAttended
Calculate the percentage, divide the classesAttended by classesHeld. You also need to cast the one of the variable to double. Otherwise, the result would be an int
Check the percentage. If it is smaller than 0.75 (75% equals 0.75), print that the student is not allowed. Otherwise, print that the student is allowed