Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ExamPreparation;
- import java.util.Scanner;
- public class FamilyTrip {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- double budget = Double.parseDouble(scanner.nextLine());
- int nights = Integer.parseInt(scanner.nextLine());
- double nightPrice = Double.parseDouble(scanner.nextLine());
- double extraCosts = Double.parseDouble(scanner.nextLine());
- extraCosts = extraCosts * budget / 100;
- if (nights > 7) {
- nightPrice = nightPrice - nightPrice * 5 / 100;
- }
- double tripSum = (nights * nightPrice) + extraCosts;
- if (tripSum <= budget) {
- System.out.printf("Ivanovi will be left with %.2f leva after vacation.", Math.abs(budget - tripSum));
- } else {
- System.out.printf("%.2f leva needed.", Math.abs(tripSum - budget));
- }
- }
- }
Add Comment
Please, Sign In to add comment