diff --git a/Emne 3/TekstTukling/Program.cs b/Emne 3/TekstTukling/Program.cs new file mode 100644 index 0000000..858df2d --- /dev/null +++ b/Emne 3/TekstTukling/Program.cs @@ -0,0 +1,61 @@ +using System; + +namespace TekstTukling +{ + class Program + { + static void Main(string[] args) + { + + Console.WriteLine("Velg 1 for å snu tekst eller 2 for å bytte e med a i tekst"); + string valg = Console.ReadLine(); + if (valg == "1") + { + Console.Clear(); + Console.WriteLine("Skriv inn tekst som skal snus: "); + string reverseText = Console.ReadLine(); + ReverseTekst(reverseText); + + } else if (valg == "2") + { + Console.Clear(); + Console.WriteLine("Skriv inn tekst hvor a skal erstatte e: "); + string vowelSwap = Console.ReadLine(); + SwapVowels(vowelSwap); + } + else + { + Console.WriteLine("Velg 1 eller 2!!"); + } + + } + + static void ReverseTekst(string reverseText) + { + for (int i = (reverseText.Length - 1) ; i >= 0; i--) + { + Console.Write(reverseText[ i ]); + } + } + + static void SwapVowels(string vowelSwap) + { + string word = ""; + + foreach (var letter in vowelSwap) + { + if (letter == 'e') + { + word += 'a'; + } + else + { + word += letter; + } + + } + Console.WriteLine(word); + } + } +} + diff --git a/Emne 3/TekstTukling/TekstTukling.csproj b/Emne 3/TekstTukling/TekstTukling.csproj new file mode 100644 index 0000000..2f4fc77 --- /dev/null +++ b/Emne 3/TekstTukling/TekstTukling.csproj @@ -0,0 +1,10 @@ + + + + Exe + net8.0 + enable + enable + + + diff --git a/Emne 3/TekstTukling/TekstTukling.sln b/Emne 3/TekstTukling/TekstTukling.sln new file mode 100644 index 0000000..2f988f6 --- /dev/null +++ b/Emne 3/TekstTukling/TekstTukling.sln @@ -0,0 +1,16 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TekstTukling", "TekstTukling.csproj", "{1EB2E2F7-E222-46FE-B478-CF98BFB228B9}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {1EB2E2F7-E222-46FE-B478-CF98BFB228B9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1EB2E2F7-E222-46FE-B478-CF98BFB228B9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1EB2E2F7-E222-46FE-B478-CF98BFB228B9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1EB2E2F7-E222-46FE-B478-CF98BFB228B9}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal