Look at your code:
Console.WriteLine("Please enter weight in kilograms:");
x = Console.ReadLine();
...
Console.WriteLine("x");
Console.WriteLine("Please enter height in meters:");
y = Console.ReadLine();
...
Console.WriteLine("y");
Year read in a value, ignore it, and print it out.
Why would you expect that to print anything other than exactly what you entered?
Then you calculate the BMI:
int x1;
x1 = 1 * 50;
...
int y1;
y1 = (int)2.4964;
...
Console.WriteLine("The BMI is" + x1 / y1);
Which - even if it worked, which it doesn't - would always print the same value!
Stop and think about what you are doing: why are you using integers to calculate a value that is not an integer? Why do you read height in meters and use integers? You will get 1 in nearly all adults, the rare 2, and 0 for a lot of children!
Integers hold "whole numbers": 0, 1, 2, 3, 4 ... (and negative whole numbers as well, of course).
Float or double numbers hold "fractional numbers": 1.6, 3.1415926, 2.7182818, ...
So when you cast 2.4964 (which would be a Giraffe, not a human) to an integer, you get ... 2.
Change your app to use
double
values throughout instead of
int
, and use the correct formula:
Body mass index - Wikipedia[
^] : weight / (height * height).
You will also need to convert the strings you read from the user to valid numbers:
double weight;
if (!double.TryParse(userInputString, out weight)
{
Console.WriteLine($"\"{userInputString}\" is not a number!");
return;
}
Stop throwing code to together, and think about what you are trying to do first.
You may find this helps:
How to Write Code to Solve a Problem, A Beginner's Guide[
^]