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

Chapter 3 Homework - Finished, All tests Passed #824

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
12 changes: 8 additions & 4 deletions Src/BootCamp.Chapter/Checks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,29 @@ public static class Checks
public static int PromptInt(string message)
{
// To do: call your implementation.
return 0;
int convertedInt = Lesson3.getThenConvertInt(message);
return convertedInt;
}

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

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

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

namespace BootCamp.Chapter
{
internal class Lesson3
{
public static int getThenConvertInt(string message)
{
Console.WriteLine(message);
var input = Console.ReadLine();
return int.Parse(input);
}

public static string getString(string message)
{
Console.WriteLine(message);
var input = Console.ReadLine();
return input;

}

public static float getStringConvertFloat(string message)
{
Console.WriteLine(message);
var input = Console.ReadLine();
return float.Parse(input);
}

public static float calcBMI(float weight, float height)
{
float BMI = ((float)(weight / (Math.Pow(height, 2))));
return BMI;
}
}
}

32 changes: 28 additions & 4 deletions Src/BootCamp.Chapter/Program.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,38 @@
using System;
using System.Collections.Generic;
using System.IO;
using Console = System.Console;

namespace BootCamp.Chapter
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Please enter an First Name: ");
var firstName = Console.ReadLine();
Console.WriteLine($"Please enter {firstName}'s Last Name: ");
var lastName = Console.ReadLine();
var fullName = firstName + " " + lastName;
Console.WriteLine($"Please enter {fullName}'s age: ");
var age = Console.ReadLine();
Console.WriteLine($"Please enter {fullName}'s Weight (kg): ");
double weight = Convert.ToDouble(Console.ReadLine());
Console.WriteLine($"Please enter {fullName}'s Height (cm): ");
double height = Convert.ToDouble(Console.ReadLine());
Console.WriteLine($"{fullName}'s is {age} years old, his weight is {weight} and his height is {height} cm");

Console.WriteLine($"{fullName}'s BMI is {BMI.GetBMI((height / 100), weight)}");
}



// BMIformula = weight (lb) / [height (in)]2 x 703
public class BMI
{
public static double GetBMI(double height, double weight)
{
return (weight / (Math.Pow(height, 2)));
}
}


}
}
}