Advertisement
Guest User

Problem 04 - Bills

a guest
Aug 22nd, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.10 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Bills
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int months = int.Parse(Console.ReadLine());
  14.             double priceWater = 0;
  15.             double priceElecticity = 0;
  16.             double priceInternet = 0;
  17.             double priceOther = 0;
  18.             double priceOtherTotal = 0;
  19.             double average = 0;
  20.             priceWater = 20 * months;
  21.             priceInternet = 15 * months;
  22.             for (int i = 1; i <= months; i++)
  23.             {
  24.                 double bill = double.Parse(Console.ReadLine());
  25.                 priceElecticity += bill;
  26.                 priceOther = (bill + 20 + 15) + (0.2 * (bill + 20 + 15));
  27.                 priceOtherTotal += priceOther;
  28.             }
  29.             average = (priceElecticity + priceInternet + priceOtherTotal + priceWater)/months;
  30.             Console.WriteLine();
  31.             Console.WriteLine($"Electricity: {priceElecticity:f2} lv");
  32.             Console.WriteLine($"Water: {priceWater:f2} lv");
  33.             Console.WriteLine($"Internet: {priceInternet:f2} lv");
  34.             Console.WriteLine($"Other: {priceOtherTotal:f2} lv");
  35.             Console.WriteLine($"Average: {average:f2} lv");
  36.         }
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement