Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String country = scanner.nextLine(),
- device = scanner.nextLine();
- double difficulty = 0, performance = 0;
- if (country.equals("Russia")) {
- if (device.equals("ribbon")) {
- difficulty = 9.100;
- performance = 9.400;
- } else if (device.equals("hoop")) {
- difficulty = 9.300;
- performance = 9.800;
- } else if (device.equals("rope")) {
- difficulty = 9.600;
- performance = 9.000;
- }
- } else if (country.equals("Bulgaria")) {
- if (device.equals("ribbon")) {
- difficulty = 9.600;
- performance = 9.400;
- } else if (device.equals("hoop")) {
- difficulty = 9.550;
- performance = 9.750;
- } else if (device.equals("rope")) {
- difficulty = 9.500;
- performance = 9.400;
- }
- } else if (country.equals("Italy")) {
- if (device.equals("ribbon")) {
- difficulty = 9.200;
- performance = 9.500;
- } else if (device.equals("hoop")) {
- difficulty = 9.450;
- performance = 9.350;
- } else if (device.equals("rope")) {
- difficulty = 9.700;
- performance = 9.150;
- }
- }
- double score = difficulty + performance;
- System.out.printf("The team of %s get %.3f on %s.\n%.2f%%\n", country, score, device, (20 - score) * 5);
- }
- }
- Решение със switch:
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String country = scanner.nextLine(),
- device = scanner.nextLine();
- double difficulty = 0, performance = 0;
- switch (country) {
- case "Russia" -> {
- switch (device) {
- case "ribbon" -> {
- difficulty = 9.100;
- performance = 9.400;
- }
- case "hoop" -> {
- difficulty = 9.300;
- performance = 9.800;
- }
- case "rope" -> {
- difficulty = 9.600;
- performance = 9.000;
- }
- }
- }
- case "Bulgaria" -> {
- switch (device) {
- case "ribbon" -> {
- difficulty = 9.600;
- performance = 9.400;
- }
- case "hoop" -> {
- difficulty = 9.550;
- performance = 9.750;
- }
- case "rope" -> {
- difficulty = 9.500;
- performance = 9.400;
- }
- }
- }
- case "Italy" -> {
- switch (device) {
- case "ribbon" -> {
- difficulty = 9.200;
- performance = 9.500;
- }
- case "hoop" -> {
- difficulty = 9.450;
- performance = 9.350;
- }
- case "rope" -> {
- difficulty = 9.700;
- performance = 9.150;
- }
- }
- }
- }
- double score = difficulty + performance;
- System.out.printf("The team of %s get %.3f on %s.\n%.2f%%\n", country, score, device, (20 - score) * 5);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement