Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ExamPrep;
- import java.util.Scanner;
- public class P02FamilyTrip {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- double budget = Double.parseDouble(scanner.nextLine());
- int countNights = Integer.parseInt(scanner.nextLine());
- double priceForOneNight = Double.parseDouble(scanner.nextLine());
- int percent = Integer.parseInt(scanner.nextLine());
- if (countNights > 7) {
- priceForOneNight = priceForOneNight * 0.95;
- double priceForAllNights = countNights * priceForOneNight;
- double priceExpenses = budget * percent / 100.0;
- double totalPrice = priceForAllNights + priceExpenses;
- double diff = Math.abs(totalPrice - budget);
- if (budget >= totalPrice) {
- System.out.printf("Ivanovi will be left with %.2f leva after vacation.", diff);
- } else {
- System.out.printf("%.2f leva needed.", diff);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement