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);
- int dancers = Integer.parseInt(scanner.nextLine());
- double points = Double.parseDouble(scanner.nextLine()),
- totalSum = dancers * points;
- String season = scanner.nextLine(),
- destination = scanner.nextLine();
- if (destination.equals("Abroad")) {
- totalSum *= 1.50;
- if (season.equals("summer")) {
- totalSum *= 0.90;
- } else {
- totalSum *= 0.85;
- }
- } else {
- if (season.equals("summer")) {
- totalSum *= 0.95;
- } else {
- totalSum *= 0.92;
- }
- }
- System.out.printf("Charity - %.2f\n", totalSum * 0.75);
- System.out.printf("Money per dancer - %.2f\n", totalSum * 0.25 / dancers);
- }
- }
- Решение с тернарен оператор:
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int dancers = Integer.parseInt(scanner.nextLine());
- double points = Double.parseDouble(scanner.nextLine()),
- totalSum = dancers * points;
- String season = scanner.nextLine(),
- destination = scanner.nextLine();
- totalSum *=
- destination.equals("Abroad")
- ? 1.50 * (season.equals("summer") ? 0.90 : 0.85)
- : (season.equals("summer") ? 0.95 : 0.92);
- System.out.printf("Charity - %.2f\n", totalSum * 0.75);
- System.out.printf("Money per dancer - %.2f\n", totalSum * 0.25 / dancers);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement