Advertisement
Monty374

PercentPassing

Oct 5th, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. package percentpasssing;
  2.  
  3. import javax.swing.JOptionPane;
  4.  
  5. public class PercentPasssing {
  6.  
  7. /**
  8. * @param args the command line arguments
  9. */
  10. public static void main(String[] args) {
  11. int a, percentRound, loop = 0;
  12. double score, loopCount, percent, pass = 0;
  13.  
  14. String num1 = JOptionPane.showInputDialog("How many scores?");
  15. a = Integer.parseInt(num1);
  16. loopCount = (double) a;
  17.  
  18. do {
  19. loop += 1;
  20. String num2 = JOptionPane.showInputDialog("Input score " + loop);
  21. score = Integer.parseInt(num2);
  22.  
  23. if (score > 70) {
  24. pass += 1;
  25. }
  26. percent = pass / loopCount * 100;
  27. } while (loop < loopCount);
  28.  
  29. percentRound = (int) percent;
  30.  
  31. System.out.print(percentRound + "% of scores passed. \n");
  32. }
  33.  
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement