Spocoman

06. Bills

Nov 20th, 2021 (edited)
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.97 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Bills
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int month = int.Parse(Console.ReadLine());
  10.             double electricity = 0;
  11.             double water = month * 20;
  12.             double internet = month * 15;
  13.             double other = 0;
  14.  
  15.             for (int i = 0; i < month; i++)
  16.             {
  17.                 double currentBill = double.Parse(Console.ReadLine());
  18.                 electricity += currentBill;
  19.                 other += (currentBill + 35) * 1.2;
  20.             }
  21.             double average = (electricity + water + internet + other) / month;
  22.  
  23.             Console.WriteLine($"Electricity: {electricity:f2} lv");
  24.             Console.WriteLine($"Water: {water:f2} lv");
  25.             Console.WriteLine($"Internet: {internet:f2} lv");
  26.             Console.WriteLine($"Other: {other:f2} lv");
  27.             Console.WriteLine($"Average: {average:f2} lv");
  28.            
  29.         }
  30.     }
  31. }
  32.  
Add Comment
Please, Sign In to add comment