Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class ExamPreparation {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- //обща цена за багажите = брой на багажите(вход) * цена за 1 багаж(тегло + брой дни)
- double priceOver20kg = Double.parseDouble(scanner.nextLine());
- double kg = Double.parseDouble(scanner.nextLine());
- int daysToTrip = Integer.parseInt(scanner.nextLine());
- int count = Integer.parseInt(scanner.nextLine());
- double pricePer = 0;
- //спрямо теглото
- if(kg < 10) {
- pricePer = 0.20 * priceOver20kg;
- } else if (kg >= 10 && kg <= 20) {
- pricePer = 0.50 * priceOver20kg;
- } else if (kg > 20){
- pricePer = priceOver20kg;
- }
- //оскъпяване -> зависи от дните до почивката
- if(daysToTrip > 30) {
- pricePer = pricePer + 0.10 * pricePer; //1.1 * pricePer
- } else if (daysToTrip >= 7 && daysToTrip <= 30) {
- pricePer = pricePer + 0.15 * pricePer; // 1.15 * pricePer
- } else if (daysToTrip < 7) {
- pricePer = pricePer + 0.40 * pricePer; //1.4 * pricePer
- }
- double totalPrice = count * pricePer;
- System.out.printf("The total price of bags is: %.2f lv.", totalPrice);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment