Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package RealMID_10_03_19;
- import java.util.Scanner;
- public class _01_Task {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int days = Integer.parseInt(scanner.nextLine());
- double budget = Double.parseDouble(scanner.nextLine());
- int people = Integer.parseInt(scanner.nextLine());
- double fuelKM = Double.parseDouble(scanner.nextLine());
- double foodPersonDay = Double.parseDouble(scanner.nextLine());
- double priceNightPerson = Double.parseDouble(scanner.nextLine());
- double hotelExp;
- if (people > 10) {
- hotelExp = (days *people * priceNightPerson) - ((days * people * priceNightPerson) * 0.25);
- } else {
- hotelExp = days * people * priceNightPerson;
- }
- double foodExp = days * people * foodPersonDay;
- double currentExp = foodExp + hotelExp;
- for (int i = 1; i <= days; i++) {
- if (currentExp >= budget) {
- break;
- }
- double km = Double.parseDouble(scanner.nextLine());
- double travelExp = km * fuelKM;
- currentExp += travelExp;
- if (i % 3 == 0 || i % 5 == 0) {
- currentExp += (currentExp * 0.4);
- }
- if (i % 7 == 0) {
- double addMoney = currentExp / people;
- currentExp -= addMoney;
- }
- }
- if (budget >= currentExp) {
- System.out.printf("You have reached the destination. You have %.2f$ budget left.", budget - currentExp);
- }
- else {
- System.out.printf("Not enough money to continue the trip. You need %.2f$ more.", currentExp - budget);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement