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);
- double priceBagOver20kg = Double.parseDouble(scanner.nextLine()),
- bagWeight = Double.parseDouble(scanner.nextLine());
- int dayBefore = Integer.parseInt(scanner.nextLine()),
- bagCount = Integer.parseInt(scanner.nextLine());
- if (bagWeight < 10) {
- priceBagOver20kg /= 5;
- } else if (bagWeight <= 20) {
- priceBagOver20kg /= 2;
- }
- if (dayBefore < 7) {
- priceBagOver20kg *= 1.40;
- } else if (dayBefore <= 30) {
- priceBagOver20kg *= 1.15;
- } else {
- priceBagOver20kg *= 1.10;
- }
- double totalPrice = priceBagOver20kg * bagCount;
- System.out.printf("The total price of bags is: %.2f lv.\n", totalPrice);
- }
- }
- ИЛИ:
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- double priceBagOver20kg = Double.parseDouble(scanner.nextLine()),
- bagWeight = Double.parseDouble(scanner.nextLine());
- int dayBefore = Integer.parseInt(scanner.nextLine()),
- bagCount = Integer.parseInt(scanner.nextLine());
- double totalPrice =
- priceBagOver20kg / (bagWeight < 10 ? 5 : bagWeight <= 20 ? 2 : 1)
- * (dayBefore < 7 ? 1.40 : dayBefore <= 30 ? 1.15 : 1.10) * bagCount;
- System.out.printf("The total price of bags is: %.2f lv.\n", totalPrice);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement