Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pull request for Homework. #808

Open
wants to merge 1 commit into
base: Chapter1/Homework/3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Src/BootCamp.Chapter/BootCamp.Chapter.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>
<TargetFramework>netcoreapp6.0</TargetFramework>
</PropertyGroup>

</Project>
17 changes: 9 additions & 8 deletions Src/BootCamp.Chapter/Checks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,27 @@ public static class Checks
{
public static int PromptInt(string message)
{
// To do: call your implementation.
return 0;
// To do: call your implementation.
return Lesson3.PromptInt(message);
}

public static string PromptString(string message)
{
// To do: call your implementation.
return "";
// To do: call your implementation.
return Lesson3.PromptString(message);

}

public static float PromptFloat(string message)
{
// To do: call your implementation.
return 0;
return Lesson3.PromptFloat(message);

}

public static float CalculateBmi(float weight, float height)
{
// To do: call your implementation.
return 0;
return Lesson3.CalculateBMI(weight, height);

}
}
}
71 changes: 71 additions & 0 deletions Src/BootCamp.Chapter/Lesson3.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.Metrics;
using System.Globalization;
using System.Text;

namespace BootCamp.Chapter
{
internal class Lesson3
{
public static void demo()
{

string name = PromptString("Enter your name: ");
string surName = PromptString("Enter your surname: ");
int age = PromptInt("Enter your age: ");
float height = PromptFloat("Enter your height(m): ");
float weight = PromptFloat("Enter your waight(Kg): ");

Console.WriteLine(name + " " + surName + " is " + age + " years old, his weight is " + weight + " kg and his height is " + height + "m.");
double bodyMassIndex = CalculateBMI(weight, height);
Console.WriteLine("Body Mass Index measured for " + name + " " + surName + " is " + bodyMassIndex);


}

public static float CalculateBMI(float weight, float height)
{
float bodyMassIndex = (weight / (height * height));
return bodyMassIndex;
}

public static int PromptInt(string Message)
{
int age;
do
{
Console.Write(Message);
if (int.TryParse(Console.ReadLine(), out age))
break;
else
Console.Write("Please enter number for age, ");
} while (true);

return age;

}

public static float PromptFloat(string Message)
{
float metrics;
do
{
Console.Write(Message);
if (float.TryParse(Console.ReadLine(), NumberStyles.Float, NumberFormatInfo.InvariantInfo , out metrics))
break;
else
Console.Write("Please enter number\\decimal,");
} while (true);
return metrics;
}

public static string PromptString(string Message)
{
string Name;
Console.Write(Message);
Name = Console.ReadLine();
return Name;
}
}
}
1 change: 1 addition & 0 deletions Src/BootCamp.Chapter/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class Program
{
static void Main(string[] args)
{
Lesson3.demo();
}
}
}
2 changes: 1 addition & 1 deletion Tests/BootCamp.Chapter.Tests/BootCamp.Chapter.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<TargetFramework>netcoreapp6.0</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>
Expand Down