"codealong" innkapsling
This commit is contained in:
parent
250764b7ef
commit
4879b3bd6f
16
Emne 3/Innkapsling/Innkapsling.sln
Normal file
16
Emne 3/Innkapsling/Innkapsling.sln
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Innkapsling", "Innkapsling\Innkapsling.csproj", "{659C61BB-980F-4911-9652-E1C407E7DCBC}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{659C61BB-980F-4911-9652-E1C407E7DCBC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{659C61BB-980F-4911-9652-E1C407E7DCBC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{659C61BB-980F-4911-9652-E1C407E7DCBC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{659C61BB-980F-4911-9652-E1C407E7DCBC}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
10
Emne 3/Innkapsling/Innkapsling/Innkapsling.csproj
Normal file
10
Emne 3/Innkapsling/Innkapsling/Innkapsling.csproj
Normal 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>
|
20
Emne 3/Innkapsling/Innkapsling/Program.cs
Normal file
20
Emne 3/Innkapsling/Innkapsling/Program.cs
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
|
||||||
|
var numbers = new int[100];
|
||||||
|
var numberCount = 0;
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Skriv et tall (eller blankt for å avslutte: ");
|
||||||
|
var numberStr = Console.ReadLine();
|
||||||
|
if (string.IsNullOrWhiteSpace(numberStr)) break;
|
||||||
|
|
||||||
|
var number = Convert.ToInt32(numberStr);
|
||||||
|
numbers[numberCount] = number;
|
||||||
|
numberCount++;
|
||||||
|
var sum = numbers.Sum();
|
||||||
|
Console.Clear();
|
||||||
|
Console.WriteLine(
|
||||||
|
$"Antall tall: {numberCount} " +
|
||||||
|
$"Sum: {sum} " +
|
||||||
|
$"Snitt: {(float)sum / numberCount}"
|
||||||
|
);
|
||||||
|
}
|
6
Emne 3/Innkapsling/Innkapsling/Stats.cs
Normal file
6
Emne 3/Innkapsling/Innkapsling/Stats.cs
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
namespace Innkapsling;
|
||||||
|
|
||||||
|
public class Stats
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue