Advertisement
Spocoman

02. Passed

Oct 15th, 2024
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.61 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. class Passed {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         double grade = Double.parseDouble(scanner.nextLine());
  7.        
  8.         if (grade >= 3) {
  9.             System.out.println("Passed!");
  10.         }
  11.     }
  12. }
  13.  
  14. Solution with ternary operator:
  15.  
  16. import java.util.Scanner;
  17.  
  18. class Passed {
  19.     public static void main(String[] args) {
  20.         Scanner scanner = new Scanner(System.in);
  21.         double grade = Double.parseDouble(scanner.nextLine());
  22.        
  23.         System.out.println(grade >= 3 ? "Passed!" : "");
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement