Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

##Write a program in# Java# to perform the following conversions.## Given: two n

ID: 3663281 • Letter: #

Question

##Write a program in# Java# to perform the following conversions.## Given: two names and their heights in inches Output: height in feet and inches Output: height in centimeters Output: height difference between the two people -------> Format needed to be followed Give two names, delimited with a semicolon. John Doe; Jane Doe; <--- provided at run-time Give me their heights, delimited by a white space. 70 66 <--- provided at run-time John Doe is 5 feet and 10 inches (177.8 cm). Jane Doe is 5 feet and 6 inches (167.6 cm). The height difference between them is 4 inches (10.2 cm).

Explanation / Answer

Here is the java code for you:

import java.io.*;
import java.util.*;
class HeightDifference
{
public static void main(String[] args) throws IOException
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String str;
System.out.print("Give 2 names delimited with semicolon(;): ");
str = br.readLine();
String[] names = str.split(";");
System.out.print("Give their heights delimited with spaces( ): ");
str = br.readLine();
String[] heights = str.split(" ");
int h1 = Integer.parseInt(heights[0]);
int h2 = Integer.parseInt(heights[1]);
System.out.println(names[0]+" is "+h1/12+" feet and "+h1%12+" inches. ("+h1*2.54+" cm).");
System.out.println(names[1]+" is "+h2/12+" feet and "+h2%12+" inches. ("+h2*2.54+" cm).");
System.out.println("The height difference between them is "+java.lang.Math.abs(h1-h2)+" inches. ");
}
}

If you have any further queries, just get back to me.