Advertisement
Spocoman

06. Speed Info

Aug 25th, 2024
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.15 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class SpeedInfo {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         double speed = Double.parseDouble(scanner.nextLine());
  7.        
  8.         if (speed <= 10) {
  9.             System.out.println("slow");
  10.         } else if (speed <= 50) {
  11.             System.out.println("average");
  12.         } else if (speed <= 150) {
  13.             System.out.println("fast");
  14.         } else if (speed <= 1000) {
  15.             System.out.println("ultra fast");
  16.         } else if (speed > 1000) {
  17.             System.out.println("extremely fast");
  18.         }
  19.     }
  20. }
  21.  
  22. ИЛИ:
  23.  
  24. import java.util.Scanner;
  25.  
  26. public class SpeedInfo {
  27.     public static void main(String[] args) {
  28.         Scanner scanner = new Scanner(System.in);
  29.         double speed = Double.parseDouble(scanner.nextLine());
  30.  
  31.         String info =
  32.                 speed <= 10 ? "slow" :
  33.                         speed <= 50 ? "average" :
  34.                                 speed <= 150 ? "fast" :
  35.                                         speed <= 1000 ? "ultra fast" : "extremely fast";
  36.  
  37.         System.out.println(info);
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement