Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class SpeedInfo {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- double speed = Double.parseDouble(scanner.nextLine());
- if (speed <= 10) {
- System.out.println("slow");
- } else if (speed <= 50) {
- System.out.println("average");
- } else if (speed <= 150) {
- System.out.println("fast");
- } else if (speed <= 1000) {
- System.out.println("ultra fast");
- } else if (speed > 1000) {
- System.out.println("extremely fast");
- }
- }
- }
- ИЛИ:
- import java.util.Scanner;
- public class SpeedInfo {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- double speed = Double.parseDouble(scanner.nextLine());
- String info =
- speed <= 10 ? "slow" :
- speed <= 50 ? "average" :
- speed <= 150 ? "fast" :
- speed <= 1000 ? "ultra fast" : "extremely fast";
- System.out.println(info);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement