Write a program that reads characters from the keyboard until a period is received. Have the
program count the number of spaces. Report the total at the end of the program.
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
VulpesRank #55 · 29.2K reputationPosted Jan 26, 2012, 11:40 PM EST
This should work:
Prime bRank #2,035 · 712 reputationPosted Jan 26, 2012, 3:59 PM EST
string ch = ".";
Console.Write("Please write as much as you want, when you finish type '.'.");
string input = Convert.ToString(Console.Read());
while (ch != input)
{
for (int index = 0; ; index++)
{
Console.WriteLine("You have typed {0} characters", input.LongCount<);
}
}
Posted Jan 27, 2012, 9:49 AM EST
Please write as much as you want, when you finish type '.'.
#@$%%#%%#$#@#egetretergdfgdfgsdgsdg.
You entered 0 space(s)
VulpesRank #55 · 29.2K reputationPosted Jan 27, 2012, 10:51 AM EST
It's counting the number of spaces entered which is what the question asked.
Posted Jan 27, 2012, 11:02 AM EST