Advertisement
fbinnzhivko

Problem04PerfectGirlfriend

Apr 22nd, 2016
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.32 KB | None | 0 0
  1. using System;
  2. class Problem04PerfectGirlfriend
  3. {
  4.     static void Main()
  5.     {
  6.         string inputLine = Console.ReadLine();
  7.         int perfectGirls = 0;
  8.         while (inputLine != "Enough dates!")
  9.         {
  10.             string[] elements = inputLine.Split('\\');
  11.             string dayOfWeek = elements[0];
  12.             string phone = elements[1];
  13.             string bra = elements[2];
  14.             string name = elements[3];
  15.  
  16.             int result = 0;
  17.             //add the digit corresponding the day
  18.             int number = 0;
  19.             switch (dayOfWeek)
  20.             {
  21.                 case "Monday": number = 1; break;
  22.                 case "Tuesday": number = 2; break;
  23.                 case "Wednesday": number = 3; break;
  24.                 case "Thursday": number = 4; break;
  25.                 case "Friday": number = 5; break;
  26.                 case "Saturday": number = 6; break;
  27.                 case "Sunday": number = 7; break;
  28.             }
  29.             result += number;
  30.  
  31.             //add the sum of the digits of the phone
  32.             for (int i = 0; i < phone.Length; i++)
  33.             {
  34.                 result += int.Parse(phone[i].ToString());
  35.             }
  36.  
  37.             //exctract the bra size number and letter
  38.             int braSize = 0;
  39.             char braSizeLetter = bra[bra.Length - 1];
  40.  
  41.             if (bra.Length == 3)
  42.             {
  43.                 braSize = int.Parse(bra.Substring(0, 2));
  44.             }
  45.             else
  46.             {
  47.                 braSize = int.Parse(bra.Substring(0, 3));
  48.             }
  49.  
  50.             //multiply the number by the ASCI code of the letter
  51.             // and add it to the result
  52.             result += (braSize * braSizeLetter);
  53.  
  54.             //take the first letter from the name and multiply its ASCI code by the name length
  55.             char firstLetter = name[0];
  56.             //substract it from the result
  57.             result -= firstLetter * name.Length;
  58.  
  59.             if (result >= 6000)
  60.             {
  61.                 Console.WriteLine("{0} is perfect for you.", name);
  62.                 perfectGirls++;
  63.             }
  64.             else
  65.             {
  66.                 Console.WriteLine("Keep searching, {0} is not for you.", name);
  67.             }
  68.             inputLine = Console.ReadLine();
  69.         }
  70.         Console.WriteLine(perfectGirls);
  71.  
  72.     }
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement