import java.util.*; public class Main{ public static void main(String[] args) { // creating a Scanner Object Scanner
Question:
import java.util.*;
public class Main{ public static void main(String[] args) { // creating a Scanner Object Scanner input = new Scanner(System.in); // variable to store weight, height and age double weight,height,age; // prompt for weight System.out.print("Enter your Weight(in pounds):"); // reading weight weight=input.nextDouble(); // prompt for Height System.out.print("Enter your Height(in inches):"); // reading height height=input.nextDouble(); //prompt for Age System.out.print("Enter your Age(in years): "); // reading age age=input.nextDouble(); // calculating Women_BMR double Women_BMR = 655 + (4.3*weight) + (4.7*height)- (4.7*age); // calculating Man_BMR double Man_BMR = 66 + (6.3*weight) + (12.9*height) -(6.8*age); // A variable to store calories per chocolate double Chocolate_Bar_calories=230; // calculating number of chocolates for Women doubleWomen_chocolates=Women_BMR/Chocolate_Bar_calories; // calculating number of chocolates for Man double Man_chocolates =Man_BMR/Chocolate_Bar_calories; // printing chocolate required for Women System.out.printf("Chocolates required for Women are%.1f",Women_chocolates); //printing chocolates required for Man System.out.printf("Chocolates required for Man are%.1f",Man_chocolates);
}}
Modify the above program to allow user to input theirheight in feet and weight in kilograms. For instance, the height is5.7 feet and weight is 90.4 kg. Your program will first convert theheight from feet to inches and weight from kg to lbs., and thenwill compute the BMR.
Example
Introduction to Java Programming, Comprehensive Version
ISBN: 978-0133761313
10th Edition
Authors: Y. Daniel Liang