Advertisement
CR7CR7

printGrade

Oct 6th, 2022
768
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.56 KB | None | 0 0
  1. public class TestVoidMethod {
  2.  2 public static void main(String[] args) {
  3.  3 System.out.print("The grade is ");
  4.  4 printGrade(78.5);
  5.  5
  6.  6 System.out.print("The grade is ");
  7.  7 printGrade(59.5);
  8.  8 }
  9.  9
  10. 10 public static void printGrade(double score) {
  11. 11 if (score >= 90.0) {
  12. 12 System.out.println('A');
  13. 13 }
  14. 14 else if (score >= 80.0) {
  15. 15 System.out.println('B');
  16. 16 }
  17. 17 else if (score >= 70.0) {
  18. 18 System.out.println('C');
  19. 19 }
  20. 20 else if (score >= 60.0) {
  21. 21 System.out.println('D');
  22. 22 }
  23. 23 else {
  24. 24 System.out.println('F');
  25. 25 }
  26. 26 }
  27. 27 }
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement