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