This is my homework :)
I made some changes and combinations with previous members. Even as my code does not work perfectly I am happy with it right now :)
---------------------------------------------
using System;
using System.Collections.Generic;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
char input;
do
{
Console.WriteLine("Enter a sentence: ");
CountWords();
Console.WriteLine("\nDo you want to try again?");
Console.WriteLine("Press Y or N");
input = Convert.ToChar(Console.ReadLine());
} while (input != 'N');
Console.WriteLine("Thank you for testing out my code :)\nPress any key to exit.");
Console.ReadKey();
}
static void CountWords()
{
string word = Console.ReadLine();
int numberOfWords = word.Split(' ').Length;
int letters = word.Length;
if (numberOfWords == 0)
{
Console.WriteLine("Please write a sentance!");
}
else if (numberOfWords == 1)
{
Console.WriteLine("There is " + numberOfWords + " word in sentence and " + letters + " letters.");
}
else if (numberOfWords >= 2)
{
Console.WriteLine("There is " + numberOfWords + " words in sentence and " + letters + " letters.");
}
}
}
}