myrdok123

Demo Conditional Statements - Lab

Sep 20th, 2024
391
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.91 KB | None | 0 0
  1. package ConditionalStatements;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Demo {
  6.  
  7.     public static void main(String[] args) {
  8.         Scanner scanner = new Scanner(System.in);
  9.         String initialPassword = "Example";
  10.         //String b = a;
  11.         //System.out.println(a == b);
  12.  
  13.         /*String password = scanner.nextLine();
  14.  
  15.         System.out.println(password.equals(initialPassword));*/
  16.  
  17.         //double grade = Double.parseDouble(scanner.nextLine());
  18.  
  19.         /*int number = Integer.parseInt(scanner.nextLine());
  20.  
  21.         boolean isPositive = number > 0;
  22.  
  23.         System.out.println(isPositive);*/
  24.  
  25.  
  26.        /* if(grade >= 3){
  27.             System.out.println("Passed!");
  28.         }*/
  29.  
  30.  
  31.        /* String color = scanner.nextLine();
  32.  
  33.         if (color.equals("red"))
  34.             System.out.println("tomato");
  35.         else
  36.             System.out.println("banana");
  37.         System.out.println("bye");*/
  38.  
  39.       /*  int number = Integer.parseInt(scanner.nextLine());
  40.  
  41.         if ( number % 2 == 0){
  42.             System.out.println("even number");
  43.         }*/
  44.  
  45.         double grade = Double.parseDouble(scanner.nextLine());
  46.  
  47.         if (grade < 3){
  48.             System.out.println("Try again!");
  49.         }else if(grade < 3.50){
  50.             System.out.printf("Your grade is: %.0f", Math.floor(grade));// 3.49 -> 3
  51.         } else if (grade <= 3.99) {
  52.             System.out.printf("Your grade is: %.0f", Math.ceil(grade));// 3.99 -> 4
  53.         }
  54.         //1. Math.floor(3.99) -> надолу -> 3
  55.         //2. Math.ceil(3.99) -> нагоре -> 4
  56.         //3. Math.abs(-100) -> Намиране на абсолютна стойност -> 100
  57.  
  58.  
  59.         System.out.printf("%.0f", 5.4);
  60.  
  61.  
  62.         String currentDay = "Monday";
  63.         if (currentDay.equals("Monday")) {
  64.             double salary = Double.parseDouble(scanner.nextLine());
  65.             System.out.println(salary);
  66.         }
  67.  
  68.     }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment