Advertisement
EvstatiZarkov

C# Exam April 2014 - StudentCables

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