So in my homework I need to write a program that asks for the users height and weight and convert it from feet, inches to meters, cm. As well as convert the weight from pounds to kilograms. The program I've got would not be able to take a measurement such as 5'7 and convert it. Here is the acutual homework question:
The program asks the name of the user. The program will prompt "What is your name?" the user types his/her name.
The program should then ask for height and weight of the user.
It should then print on separate lines, "Name of the User" your height in metric system is (prints out the height in Meters and cm. For example, your height in metric system is 1 meter 45 cm.
It should then print the weight in KG and grams (same as above your weight in metric system is ----)
Here is what I have come up with thus far:
package extracredit;
/**
*
* @author Kent
*/
import java.util.Scanner;
public class Extracredit {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("What is your name? ");
String name = in.next();
System.out.println("What is your height? ");
Double Height = in.nextDouble();
System.out.println("What is your weight? ");
Double Weight = in.nextDouble();
System.out.println(name);
System.out.print("Your height in metric system: ");
System.out.println(Height * .3048);
System.out.println("Your weight in kg: ");
System.out.println(Weight*0.453592);
}
}