Advertisement
dimipan80

Exam 8. Student Cables

Jun 21st, 2014
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.20 KB | None | 0 0
  1. namespace _2.StudentCables
  2. {
  3.     using System;
  4.  
  5.     public class StudentCables
  6.     {
  7.         public static void Main(string[] args)
  8.         {
  9.             checked
  10.             {
  11.                 int numCables = int.Parse(Console.ReadLine());
  12.  
  13.                 int cableLength = 0;
  14.                 int countCables = 0;
  15.                 for (int i = 0; i < numCables; i++)
  16.                 {
  17.                     int cable = int.Parse(Console.ReadLine());
  18.                     string measure = Console.ReadLine();
  19.                     if (measure == "meters")
  20.                     {
  21.                         cable *= 100;
  22.                     }
  23.  
  24.                     if (cable >= 20)
  25.                     {
  26.                         cableLength += cable;
  27.                         countCables++;
  28.                     }
  29.                 }
  30.  
  31.                 if (countCables > 1)
  32.                 {
  33.                     cableLength -= 3 * (countCables - 1);
  34.                 }
  35.  
  36.                 int studentCables = cableLength / 504;
  37.                 int remainCable = cableLength % 504;
  38.  
  39.                 Console.WriteLine(studentCables);
  40.                 Console.WriteLine(remainCable);
  41.             }
  42.         }
  43.     }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement