TekstTukling

This commit is contained in:
Geir Okkenhaug Jerstad 2024-11-19 12:59:15 +01:00
parent 09947e3059
commit 2c3f93d0c4
3 changed files with 87 additions and 0 deletions

View file

@ -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);
}
}
}

View file

@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View file

@ -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