Answer to Question #11968 in Java | JSP | JSF for James
2012-07-17T08:38:51-04:00
Write a code that takes in a person's height in inches and weight in pounds and outputs it in centimeters and kilograms. (1 in = 2.54cm , 1kg = 2.2 lbs.)
Can you help me how to write the code?
Thanks
1
2012-07-19T07:38:44-0400
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Test { public static void main(String[] args) throws IOException { double height=0; double weight=0; BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); System.out.println("Enter height: "); height=Double.parseDouble(br.readLine()); System.out.println("Enter weight: "); weight=Double.parseDouble(br.readLine()); height=height*2.54; weight=weight*2.2; System.out.println("Height: "+height); System.out.println("Weight: "+weight); } }
Need a fast expert's response?
Submit order
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS !
Learn more about our help with Assignments:
Java JSP JSF
Comments
Leave a comment