The BMI is defined as the body mass kilograms divided by the square of the body

# The bmi is defined as the body mass kilograms divided

This preview shows page 9 - 11 out of 11 pages.

The BMI is defined as the body mass (kilograms) divided by the square of the body height (meters). Extend BMI.java to calculate a BMI based on height in meters and weight in kilograms. Height (meters): 1.6 Weight (kilograms): 65 BMI: 25.390624999999996 Adapt to take input in inches and pounds. Find the appropriate formulas and constants on the web. There are calculators on the web that you may use to compare results. Express any constant values, such as meters in an inch, as a constant: final double METERS_IN_INCH = 0.0254; Height (inches): 63 1.6001999999999998(meters) Weight (pounds): 143 64.86370891143507(kilograms) BMI: 25.331053134448013 Adapt further to take input in feet, inches and pounds. Height (feet): 5 Height (inches): 3 1.6001999999999998(meters) Weight (pounds): 143 64.86370891143507(kilograms) BMI: 25.331053134448013 Exercise H: Hello World Run this HelloWorld.java program and see if you can figure out how it works. 1.What does the seed for Random do? 2.What does += mean for Strings? 3.What does the following do? 4.Why was'`'chosen? 5.Why was 27 chosen? 6.Why were those specific seeds chosen?
15.String str = " r g h "; String.trim(); //Will this compile? 16.int length = " strange looking".length(); //why does this work? 17. String str2 = "Careful reading will save " + " lots of time debugging."; System.out.println( str2.substring( str2.indexOf('e') + 1, str2.indexOf('o')).trim()); //What will be print out? Describe in your own words what the substring, indexOf and trim methods do. 18. String str = "he" + (9+2) + 'o'; String str2 = str.toUpperCase(); System.out.println( str2); 19.int num = '1';//will this data type conversion work? 20. Character ch = new Character('A'); System.out.println( ch.isLowerCase()); 21. Random numGenerator = new Random(); System.out.println( "number: " + Random.nextInt()); //What is wrong and how do you fix? 22. Random rand = new Random(); //remember to import java.util.Random int num1 = rand.nextInt(); int num2 = rand.nextInt(); int num3 = rand.nextInt(); //Will the nextInt() method return the same value each time? //What is the range of possible values returned? //Each time you run this will the values returned be the same or different?

#### You've reached the end of your free preview.

Want to read all 11 pages?

• Fall '19
• partner