import jeliot.io.*; import java.util.*; public class MyClass { public static voi
ID: 3615346 • Letter: I
Question
import jeliot.io.*;
import java.util.*;
public class MyClass {
public static void main(String[]args)
{
Scanner Kybd = new Scanner(System.in);
System.out.println("Input gender: ");
String gender = Kybd.next();
System.out.println("Height of mother in inches:");
int Hmother = Kybd.nextInt();
System.out.println("Height of father in inches:");
int Hfather = Kybd.nextInt();
while (Hmother !=68 || Hfather!=77)
{
System.out.println("Height of mother in inches:");
Hmother = Kybd.nextInt();
System.out.println("Height of father in inches:");
Hfather = Kybd.nextInt();
}
}
}
Explanation / Answer
please rate- thanks import java.util.*; public class untitled { public static void main(String[]args) {int Hmother,Hfather,ft; String gender; Scanner Kybd = new Scanner(System.in); System.out.println("Input gender(none to exit):"); gender = Kybd.next(); while(gender.compareTo("none")!=0) { System.out.println("Heightof mother in feet: "); Hmother =Kybd.nextInt()*12; System.out.println("Height of mother in inches: "); Hmother +=Kybd.nextInt(); System.out.println("Height of father in feet: "); Hfather =Kybd.nextInt()*12; System.out.println("Height of father in inches: "); Hfather +=Kybd.nextInt(); if(gender.compareTo("male")==0) ft=(int)(((double)Hmother * 13./12.) +(double)Hfather)/2; else ft=(int)(((double)Hfather* 12./13.) +(double)Hmother)/2; System.out.println("Height of mother in inches: "+Hmother); System.out.println("Height of father in inches: "+Hfather); System.out.println("Estimated height of "+gender+" child:"+ft/12+" ft,"+ft%12+" in "); System.out.println("Input gender(none to exit): "); gender =Kybd.next(); } } } sample run ----jGRASP exec: java untitled Input gender(none to exit): male Height of mother in feet: 5 Height of mother in inches: 8 Height of father in feet: 6 Height of father in inches: 5 Height of mother in inches: 68 Height of father in inches: 77 Estimated height of male child: 6 ft,3 in Input gender(none to exit): none ----jGRASP: operation complete.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.