Guest User

Computer Firm

a guest
Jan 5th, 2019
648
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.22 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _05._Computer_Firm
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int computers = int.Parse(Console.ReadLine());
  10.             double totalSales = 0;
  11.             double totalRating = 0;
  12.  
  13.             for (int i = 0; i < computers; i++)
  14.             {
  15.                 int currentNumber = int.Parse(Console.ReadLine());
  16.                 int rating = currentNumber % 10;
  17.                 int possibleSales = currentNumber / 10;
  18.                 totalRating += rating;
  19.  
  20.                 switch (rating)
  21.                 {
  22.                     case 3:
  23.                         totalSales += 0.5 * possibleSales;
  24.                         break;
  25.                     case 4:
  26.                         totalSales += 0.7 * possibleSales;
  27.                         break;
  28.                     case 5:
  29.                         totalSales += 0.85 * possibleSales;
  30.                         break;
  31.                     case 6:
  32.                         totalSales += possibleSales;
  33.                         break;
  34.                 }
  35.             }
  36.  
  37.             Console.WriteLine($"{totalSales:f2}");
  38.             Console.WriteLine($"{totalRating / computers:f2}");
  39.         }
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment