Assignemnt #26 and Calculator with User Input
Code
/// Name: Kyle Ivy
/// Period: 5
/// Program Name: CalcUserInput
/// File Name: CalcUserInput.java
/// Date Finished: 10/8/2015
import java.util.Scanner;
public class CalcUserInput {
public static void main( String[] args ) {
Scanner keyboard = new Scanner(System.in);
double m, kg, bmi, pounds;
int feet, inches, total;
System.out.println( "Hello. I will calculate your BMI for you.");
System.out.println();
System.out.print( "What is your height in feet? " );
feet = keyboard.nextInt();
System.out.print( "So you're " + feet + " feet tall and how many inches? " );
inches = keyboard.nextInt();
System.out.print( "Alright, now what is your weight in pounds? " );
pounds = keyboard.nextDouble();
kg = pounds*.453592;
total = feet*12 + inches;
m= total*.0254;
bmi = kg / m*m;
System.out.println( "Your BMI is " + bmi + "!" );
}
}
prog26.PNG