Level 7 - String operations 0 of 9 activities solved
  1. Debit card Not yet solved
  2. Teacher code Not yet solved
  3. Caesar cipher Not yet solved
  4. Airline ticket Not yet solved
  5. Disemvowel Not yet solved
  6. Your move Not yet solved
  7. Tweet Not yet solved
  8. Valid address Not yet solved
  9. Palindrome Not yet solved
Next series Level 8 - Files and exceptions
Level 7 - String operations

Teacher code

Sign in to hand in your solution and get feedback.

// Teacher code program using System; class Submission { // ------------------------- // Subprograms // ------------------------- static string tcode(string teacher) { string[] letters = new string[2]; letters[0] = teacher.Substring(0, 1); int space = teacher.IndexOf(" "); letters[1] = teacher.Substring(space + 1, 2); string teacher_code = string.Join("", letters); teacher_code = teacher_code.ToUpper(); return teacher_code; } // ------------------------- // Main program // ------------------------- public static void Main(string[] args) { Console.WriteLine("Enter the name of the teacher: "); string teacher = Console.ReadLine(); string teacher_code = tcode(teacher); Console.WriteLine(teacher_code); } }