import java.util.Scanner; public class Chapter2_14 { public static void main(String[] args){ Scanner input = new Scanner(System.in); System.out.println("Enter weight in pounds: "); double pounds = input.nextDouble(); System.out.println("Enter height in inches: "); double inches = input.nextDouble(); final double b = 0.45359237; final double y = 0.0254; double BMI = (int)(b * pounds / Math.pow(y * inches,2) * 10000) / 10000.0; System.out.println("BMI is " + BMI); } }
import java.util.Scanner; public class Chapter2_15 { public static void main(String[] args){ Scanner input = new Scanner(System.in); System.out.println("Enter x1 and y1: "); double x1 = input.nextDouble(); double y1 = input.nextDouble(); System.out.println("Enter x2 and y2: "); double x2 = input.nextDouble(); double y2 = input.nextDouble(); double distance = Math.pow((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1), 0.5); System.out.println("The distance between the two points is " + distance); } }