Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace StringEdit
- {
- class Program
- {
- static void Main(string[] args)
- {
- string sentenceCorrection;
- int incorrectIndex = 0;
- char replacementChar;
- int sentenceLength = 0;
- Program FixTypo = new Program();
- Console.WriteLine("Which sentence do you want correcting?");
- sentenceCorrection = Console.ReadLine();
- sentenceCorrection = sentenceCorrection.ToLower();
- sentenceLength = sentenceCorrection.Length - 1;
- Console.WriteLine("At which index do you want it correcting? (maximum " + sentenceLength + ")");
- incorrectIndex = int.Parse(Console.ReadLine());
- Console.WriteLine("What do you want to change the character to?");
- replacementChar = char.Parse(Console.ReadLine());
- FixTypo.FixTypo(sentenceCorrection, incorrectIndex, replacementChar);
- }
- public string FixTypo(string sentenceCorrection, int incorrectIndex, char replacementChar)
- {
- string correctedSentence = "";
- char indexLetter;
- indexLetter = sentenceCorrection[incorrectIndex];
- correctedSentence = sentenceCorrection.Replace(indexLetter, replacementChar);
- Console.WriteLine("The corrected sentence is as follows: ");
- Console.WriteLine(correctedSentence);
- return correctedSentence;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement