Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package PodgotovkaZaIzpit;
- import java.util.Scanner;
- public class BurgerBus {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int numCities = Integer.parseInt(scanner.nextLine());
- double totalProfit = 0;
- for (int i = 0; i < numCities; i++) {
- String cityName = scanner.nextLine();
- double income = Double.parseDouble(scanner.nextLine());
- double expenses = Double.parseDouble(scanner.nextLine());
- double profit = income - expenses;
- if ((i + 1) % 3 == 0) {
- profit -= expenses * 0.5; // Subtract 50% expenses for special event
- }
- if ((i + 1) % 5 == 0) {
- profit -= income * 0.1; // Subtract 10% loss due to rain
- }
- totalProfit += profit;
- System.out.printf("In %s Burger Bus earned %.2f leva.%n", cityName, profit);
- }
- System.out.printf("Burger Bus total profit: %.2f leva.%n", totalProfit);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment