noob here -- first java program -- please take a look
Im making a program that converts your BMI.
When I go to run it, I get errors.
Here is my code:
------------------------------------------------------------------------------
import java.util.Scanner;
public class BmiCalculator {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("Enter weight in pounds: ");
long weight = input.nextlong();
System.out.print("Enter height in inches: ");
long height = input.nextlong();
long BMI =(weight*.45359237)/(height*.0254);
System.out.print(BMI);
}
}
--------------------------------------------------------------------------
Here is the outout in CMD:
---------------------------------------------------------------------------
c:\java>javac BmiCalculator.java
BmiCalculator.java:12: error: cannot find symbol
long weight = input.nextlong();
^
symbol: method nextlong()
location: variable input of type Scanner
BmiCalculator.java:15: error: cannot find symbol
long height = input.nextlong();
^
symbol: method nextlong()
location: variable input of type Scanner
BmiCalculator.java:17: error: possible loss of precision
long BMI =(weight*.45359237)/(height*.0254);
^
required: long
found: double
3 errors
-----------------------------------------------------------------------------------
Re: noob here -- first java program -- please take a look
Check your spelling. Java is case sensitive.
Please wrap you code in code tags. See: BB Code List - Java Programming Forum
Re: noob here -- first java program -- please take a look
Please go through the Forum Rules -- particularly the third paragraph
db