/******************************************************/ /* Introduction to Programming */ /* By Dr. ANTF */ /* www.antf.net */ /* Copyright 2015 */ /* */ /* C# 309 - Problem 8: Stream of Characters */ /******************************************************/ using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace DOS { class Program { static void Main(string[] args) { int countA = 0, countE = 0; char x = '!'; while(x != '~') { x = Console.ReadKey().KeyChar; if (x == 'a') countA++; else if (x == 'e') countE++; } Console.WriteLine("\n\nYou pressed \'a\' {0} times.", countA); Console.WriteLine("You pressed \'e\' {0} times.", countE); Console.ReadKey(); } } }