Advertisement
Daniel_007

05. Family House

Nov 2nd, 2019
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.94 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Exam
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int howManyMonths = int.Parse(Console.ReadLine());
  10.             double elect = 0;
  11.             double moneyAll = 0;
  12.             double electAll = 0;
  13.             double OtherAll = 0;
  14.             for (int i = 0; i < howManyMonths; i++)
  15.             {
  16.                 elect = double.Parse(Console.ReadLine());
  17.                 electAll += elect;
  18.                 OtherAll += (elect + 20 + 15)*1.2;
  19.                 moneyAll += (elect + 20 + 15);
  20.             }
  21.             Console.WriteLine($"Electricity: {electAll:F2} lv");
  22.             Console.WriteLine($"Water: {howManyMonths*20:F2} lv");
  23.             Console.WriteLine($"Internet: {howManyMonths*15:F2} lv");
  24.             Console.WriteLine($"Other: {OtherAll:F2} lv");
  25.             Console.WriteLine($"Average: {(moneyAll+OtherAll)/howManyMonths:F2} lv");
  26.         }
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement