0

Why are no decimals being displayed in the result? The answer should not be rounded to 30 given inputs of weight=220 and height=71 (this is the example I was given). I do not know why it is being rounded to an int when I have not intended for that to happen. What should I do? Code below:

using System;
                    
public class Program
{
    public static void Main()
    {
        
        Console.WriteLine("Welcome to our BMI Calculator!");
        
        Console.WriteLine("Please enter your first and last name");
        string name = Console.ReadLine();
        
        Console.WriteLine("Please enter your weight in pounds rounded to the nearest pound");
        int weight = Convert.ToInt32(Console.ReadLine());
        
        Console.WriteLine("Please enter your height in inches rounded to the nearest inch");
        int height = Convert.ToInt32(Console.ReadLine());

        int height_squared = height*height;
        
        decimal result = Convert.ToDecimal(703*weight/height_squared);
        
        Console.WriteLine("Your BMI is: "+result);
        
        Console.WriteLine("Thank you for using our BMI Calculator!");
        
    }
}

0 Answers0