fork download
  1. import java.util.*;
  2.  
  3. class Ideone {
  4. public static void main(String[] args) {
  5. Scanner inp = new Scanner(System.in);
  6.  
  7. System.out.println("Enter the attended");
  8. float attended = inp.nextInt();
  9. float og = attended;
  10.  
  11. System.out.println("Enter the total");
  12. float total = inp.nextInt();
  13.  
  14. System.out.println("Enter the value");
  15. float value = inp.nextInt();
  16.  
  17. System.out.println("No. of Classes per week");
  18. float week = inp.nextInt();
  19.  
  20. System.out.println(attended + " " + total + " " + value);
  21. float percentage = (attended / total) * 100;
  22. System.out.println(percentage);
  23.  
  24. while (percentage < 75) {
  25. attended += value;
  26. total += value;
  27. percentage = (attended / total) * 100;
  28. }
  29.  
  30. System.out.println("Attendance needed " + Math.floor(attended) + " " + Math.floor(total));
  31.  
  32. float classesNeeded = (float) ((Math.floor(attended) - og) / value);
  33. System.out.println("No of classes needed " + classesNeeded);
  34.  
  35. float weeksNeeded = classesNeeded / week;
  36. System.out.println("No. of Weeks " + weeksNeeded);
  37.  
  38. inp.close();
  39. }
  40. }
  41.  
Success #stdin #stdout 0.25s 61508KB
stdin
42
66
2
3
stdout
Enter the attended
Enter the total
Enter the value
No. of Classes per week
42.0 66.0 2.0
63.636364
Attendance needed 72.0 96.0
No of classes needed 15.0
No. of Weeks 5.0