neZnam121

Untitled

Oct 24th, 2021
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.46 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _01.BurgerBus
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int numberOfCities = int.Parse(Console.ReadLine());
  10.             double totalProfit = 0;
  11.             for (int i = 1; i <= numberOfCities; i++)
  12.             {
  13.                 string nameOfTheCity = Console.ReadLine();
  14.                 double income = double.Parse(Console.ReadLine());
  15.                 double expenses = double.Parse(Console.ReadLine());
  16.                 double leftMoney = income - expenses;
  17.                 if (i % 5 == 0 && i % 3 == 0)
  18.                 {
  19.                     leftMoney -= leftMoney * 0.1;
  20.                     totalProfit += leftMoney;
  21.                     continue;
  22.                 }
  23.                 if (i % 5 == 0)
  24.                 {
  25.                     income -= income * 0.1;
  26.                     leftMoney = income - expenses;
  27.                     totalProfit += leftMoney;
  28.                     Console.WriteLine($"In {nameOfTheCity:f2} Burger Bus earned {leftMoney:f2} leva.");
  29.                     continue;
  30.                 }
  31.                 if (i % 3 == 0)
  32.                 {
  33.                     leftMoney -= expenses * 0.5;
  34.                 }
  35.                     totalProfit += leftMoney;
  36.                 Console.WriteLine($"In {nameOfTheCity} Burger Bus earned {leftMoney:f2} leva.");
  37.             }
  38.             Console.WriteLine($"Burger Bus total profit: {totalProfit:f2} leva.");
  39.         }
  40.     }
  41. }
  42.  
Advertisement
Add Comment
Please, Sign In to add comment