borovaneca

BurgerBus

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