6.2k views
0 votes
Write a java program using switch that determine if the employee will not be allowed to attend the class if his/her attendance is less than 80% and you will ask your user to input:

a. How many classes were held?
b. Attendance at classes
c. Display the percentage of class attended
d. Output if he/she allowed to attend the class or not

User Hemeroc
by
4.6k points

1 Answer

6 votes

import java.util.Scanner;

class check_st {

public static void main(String[] args) {

Scanner f = new Scanner(System.in);

double x,y,d;

System.out.println("How many classes were held?: ");

x = f.nextInt();

System.out.println("Attendance in class: ");

y = f.nextInt();

d = (y/x)*100.0;

float k = (float) Math.round(d * 100) / 100;

System.out.println("The percentage of class attended: %"+k);

int m = (k<80.0) ? 0 : 1;

switch(m)

case 0:

System.out.println("Failed the course!");

break;

case 1:

System.out.println("Passed the course!");

break;

default:

;;

}

}

User TechV
by
5.6k points