Advertisement
Ligh7_of_H3av3n

FixedCode_01_BurgerBus

Feb 18th, 2024
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.17 KB | None | 0 0
  1. package PodgotovkaZaIzpit;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Pomosht {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.  
  9.  
  10.         int cities = Integer.parseInt(scanner.nextLine());
  11.  
  12.         double totalProfitFromTheTour = 0.0;
  13.  
  14.         for (int city = 1; city <= cities; city++) {
  15.             String cityName = scanner.nextLine();
  16.             double income = Double.parseDouble(scanner.nextLine());
  17.             double expenses = Double.parseDouble(scanner.nextLine());
  18.  
  19.             double totalProfitForEachCity = income - expenses;
  20.  
  21.             if (city % 3 == 0) {
  22.                 double additionalSpending = 0.5 * expenses;
  23.                 totalProfitForEachCity -= additionalSpending;
  24.             }
  25.  
  26.             if (city % 5 == 0) {
  27.                 totalProfitForEachCity -= 0.1 * income; // Loss due to rain
  28.             }
  29.  
  30.             totalProfitFromTheTour += totalProfitForEachCity;
  31.  
  32.             System.out.printf("In %s Burger Bus earned %.2f leva.%n", cityName, totalProfitForEachCity);
  33.         }
  34.  
  35.         System.out.printf("Burger Bus total profit: %.2f leva.%n", totalProfitFromTheTour);
  36.     }
  37. }
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement