Advertisement
Atanasov_88

Illiuminati

Jul 6th, 2015
447
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.70 KB | None | 0 0
  1. using System;
  2.  
  3.     class Program
  4.     {
  5.         static void Main()
  6.         {
  7.             string input = Console.ReadLine();
  8.             input = input.ToUpper();
  9.             char[] vowels = new char[input.Length];
  10.             vowels = input.ToCharArray();
  11.  
  12.             int counter = 0;
  13.             int sum = 0;
  14.  
  15.             for (int i = 0; i < input.Length; i++)
  16.             {
  17.  
  18.                 switch (vowels[i])
  19.                 {
  20.                     case 'A': counter++; sum = sum + 65;
  21.                         break;
  22.                     case 'E': counter++; sum = sum + 69;
  23.                         break;
  24.                     case 'I': counter++; sum = sum + 73;
  25.                         break;
  26.                     case 'O': counter++; sum += 79;
  27.                         break;
  28.                     case 'U': counter++; sum += 85;
  29.                         break;
  30.                     default:
  31.                        
  32.                         break;
  33.                        
  34.                 }
  35.             }
  36.             Console.WriteLine(counter);
  37.             Console.WriteLine(sum);
  38.            
  39.            
  40.            
  41.            
  42.            
  43.            
  44.            
  45.         }
  46.     }
  47. //The illuminati are an ancient, very secret society that very secretly rules the world. They’ve managed to keep their existence secret by using a very secretive way of communication. Their secret is that they incorporate their secret messages into popular (non-secret) movies.
  48. Your task is to extract the meaning of some movie lines. The messages are actually codes that can be extracted by summing the secret values of every vowel in the message. The values of the vowels are as follows: A = 65, E = 69, I = 73, O = 79, U = 85. The values apply for both upper and lowercase letters. For example, ‘I am Batman!’ has a total of 4 vowels: three times ‘A’ and one time ‘I’ and their sum is: 3 * 65 + 1 * 73 = 268.
  49. Input
  50. • The input data should be read from the console.
  51. • The only input line holds the message that has to be deciphered.
  52. The input data will always be valid and in the format described. There is no need to check it explicitly.
  53. Output
  54. • The output data should be printed on the console.
  55. • On the first output line you must print the number of vowels in the message.
  56. • On the second output line you must print the sum of all the vowels in the message.
  57. Constraints
  58. • The length of the message will be between 1 and 800 000 characters.
  59. • Allowed working time for your program: 0.1 seconds.
  60. • Allowed memory: 16 MB.
  61. Examples
  62. Input   Output
  63. Listen very carefully, I shall say this only once.  13
  64. 933
  65. Heeeeeeere’s JOHNNY!  9
  66. 631
  67. Don’t ask me about my business!   9
  68. 669
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement