Ryan Velo

Ryan Velo

  • NA
  • 4
  • 2.7k

C# Error (Does not exist in current context)

Oct 3 2016 11:56 AM
Hello! I've been trying to write a two class bmi calculator for my homework assignment, I have two errors left in the main method saying inputheight and inputweight do not exist.
Any input would be appreciated
 
Code
 
using System;
namespace Calculator
{
public class BMICalc
{
private const
decimal REQ = 703;
private int weightPerson;
private int heightPerson;
public BMICalc()
{
}
public BMICalc(int weiP, int heiP)
{
this.weightPerson = weiP;
this.heightPerson = heiP;
}
public decimal SetBmi()
{
decimal bmi;
bmi = (this.weightPerson * BMICalc.REQ) / (this.heightPerson * this.heightPerson);
if (bmi < 18.5m)
{
Console.WriteLine("UnderWeight");
Console.ReadLine();
}
if (bmi > 18.5m && bmi < 25.0m)
{
Console.WriteLine("Normal");
Console.ReadLine();
}
if (bmi > 25.0m && bmi < 29.9m)
{
Console.WriteLine("OverWeight");
Console.ReadLine();
}
if (bmi > 29.9m && bmi < 40.0m)
{
Console.WriteLine("Obese");
Console.ReadLine();
}
return bmi;
}
public override string ToString()
{
return "\tCalculator" +
"\n\n Weight:" + this.weightPerson +
"\n\n Height:" + this.heightPerson +
"\n\n BMI Score:" + SetBmi().ToString("C");
}
}
}
 
(2nd part) 
 
namespace Calculator
{
public class App
{
public static void Main() //
{
int heiP, weiP;
heiP = InputHeight();
Console.WriteLine("\nPlease enter height"); // main error here
weiP = InputWeight();
Console.WriteLine("\nPlease enter weight");
BMICalc bmiCal = new BMICalc(heiP, weiP);
Console.Clear();
Console.WriteLine(bmiCal.ToString());
Console.ReadKey();
}
}
}
 

Answers (1)