Skip to content
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
17 changes: 10 additions & 7 deletions Src/BootCamp.Chapter/Checks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,29 @@ public static class Checks
{
public static int PromptInt(string message)
{
// To do: call your implementation.
return 0;
// To do: call your implementation.
//
return Lesson3.GetInt(message);
}

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

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

public static float CalculateBmi(float weight, float height)
{
// To do: call your implementation.
return 0;
// To do: call your implementation.
//
return Lesson3.CalculateBMI(weight, height);
}
}
}
46 changes: 46 additions & 0 deletions Src/BootCamp.Chapter/Lesson3.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using System.Security.Cryptography.X509Certificates;
using System.Text;

namespace BootCamp.Chapter
{
public class Lesson3
{
public static void Demo()
{
var userOne = GetUserInfo();
Console.WriteLine($"{userOne}");

var userTwo = GetUserInfo();
Console.WriteLine($"{userTwo}");
}

public static string GetInput(string message)
{
Console.Write($"{message}");
var input = Console.ReadLine();
return input;
}
public static int GetInt(string message) => int.Parse(GetInput(message));
public static float GetFloat(string message) => float.Parse(GetInput(message));
public static float CalculateBMI(float weight, float height) => weight / (float)Math.Pow(height, 2);

public static string GetUserInfo()
{
var name = GetInput("name: ");
var surName = GetInput("surname: ");
var age = GetInt("age: ");
var weight = GetFloat("weight: ");
var height = GetFloat("height: ");
var bmi = CalculateBMI(weight, height);

return PrintUserInfo(name, surName, age, weight, height);
}

public static string PrintUserInfo(string name, string sureName, int age, float weight, double height)
{
return $"{name} {sureName} is {age} years old, his weight is {weight} kg and his height is {height} cm.";
}
}
}
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();
}
}
}