14,699,322 members
1.00/5 (1 vote)
See more:
```using System;
using System.Diagnostics;

namespace bmimetric.cs
{
class bmimetric
{

public static object Main(string[] args)
{
String x, y;
int x1;
x1 = 1 * 50;
Console.WriteLine("x");
int y1;
y1 = (int)2.4964;
Console.WriteLine("y");
Console.WriteLine("The BMI is" + x1 / y1);
}
}
}```

What I have tried:

I have tried math.pow i have tried float i have tried everything... also if someone knows a way I can get an easier version of visual studios on a mac please tell me
Posted
Updated 10-Oct-20 21:23pm

## Solution 2

```            Console.WriteLine("Please enter weight in kilograms:");
...
Console.WriteLine("x");
...
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[^]