From d828df8e92ac03490216f4cf90bd13ec23f91a91 Mon Sep 17 00:00:00 2001 From: munaxshe <29699568@students.lincoln.ac.uk> Date: Thu, 31 Jul 2025 13:56:52 +0100 Subject: [PATCH] Small improvements for clarity and user messages - Added a comment at the top of Main to explain what it does - Made the input prompt and error messages more user-friendly - Tidied up the output heading and added a "Processing complete!" line --- TextProcessing/Program.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/TextProcessing/Program.cs b/TextProcessing/Program.cs index 4f73f2f..e96cf3a 100644 --- a/TextProcessing/Program.cs +++ b/TextProcessing/Program.cs @@ -2,22 +2,21 @@ using System.Collections.Generic; using System.IO; using System.Linq; -using System.Text; using System.Text.RegularExpressions; -using System.Threading.Tasks; namespace TextProcessing { internal class Program { + // Main program: asks for a file, reads its contents, and counts unique word occurrences. static void Main(string[] args) { - Console.WriteLine("Enter the full path of the text file: "); + Console.WriteLine("Please enter the path to the text file you want to process:"); string filePath = Console.ReadLine(); if (!File.Exists(filePath)) { - Console.WriteLine("The file does not exist. Exiting..."); + Console.WriteLine($"Sorry, the file \"{filePath}\" does not exist. Exiting program."); return; } @@ -45,8 +44,10 @@ static void Main(string[] args) } } + Console.WriteLine("\nProcessing complete!\n"); + // Output word counts - Console.WriteLine("\n Word occurrences:"); + Console.WriteLine("Word occurrences:"); foreach (var pair in wordCounts.OrderBy(p=>p.Key)) { Console.WriteLine($"{pair.Key}: {pair.Value}"); @@ -55,6 +56,5 @@ static void Main(string[] args) Console.WriteLine($"\nTotal number of unique words: {wordCounts.Count}"); Console.ReadKey(); } - } }