Here is the code for you: import java.util.*; class HeightOfChild { public static void main(String[] args) { Scanner sc = new Scanner(System.in); double childHeight; int feet, inches, fatherHeight, motherHeight; while(true) { System.out.print(\"Enter the gender of child (M)ale or (F)emale: \"); char gender = sc.next().charAt(0); System.out.print(\"Choose your input style: 1. Feet & Inches. 2. Inches: \"); int inputStyle = sc.nextInt(); if(inputStyle == 1) { System.out.println(\"Enter the height of the mother: \"); System.out.print(\"Feet: \"); feet = sc.nextInt(); System.out.print(\"Inches: \"); inches = sc.nextInt(); motherHeight = feet * 12 + inches; System.out.println(\"Enter the height of the father: \"); System.out.print(\"Feet: \"); feet = sc.nextInt(); System.out.print(\"Inches: \"); inches = sc.nextInt(); fatherHeight = feet * 12 + inches; } else { System.out.print(\"Enter the height of mother in inches: \"); motherHeight = sc.nextInt(); System.out.print(\"Enter the height of father in inches: \"); fatherHeight = sc.nextInt(); } if(gender == \'M\') childHeight = ((motherHeight * 13 / 12.0) + fatherHeight) / 2; else childHeight = ((fatherHeight * 12 / 13.0) + motherHeight) / 2; System.out.println(\"The height of the child is: \" + childHeight); System.out.print(\"Do you want to calculate again...(Y/N): \"); char again = sc.next().charAt(0); if(again != \'Y\') return; } } } If you need any refinements, just get back to me. Solution Here is the code for you: import java.util.*; class HeightOfChild { public static void main(String[] args) { Scanner sc = new Scanner(System.in); double childHeight; int feet, inches, fatherHeight, motherHeight; while(true) { System.out.print(\"Enter the gender of child (M)ale or (F)emale: \"); char gender = sc.next().charAt(0); System.out.print(\"Choose your input style: 1. Feet & Inches. 2. Inches: \"); int inputStyle = sc.nextInt(); if(inputStyle == 1) { System.out.println(\"Enter the height of the mother: \"); System.out.print(\"Feet: \"); feet = sc.nextInt(); System.out.print(\"Inches: \"); inches = sc.nextInt(); motherHeight = feet * 12 + inches; System.out.println(\"Enter the height of the father: \"); System.out.print(\"Feet: \"); feet = sc.nextInt(); System.out.print(\"Inches: \"); inches = sc.nextInt(); fatherHeight = feet * 12 + inches; } else { System.out.print(\"Enter the height of mother in inches: \"); motherHeight = sc.nextInt(); System.out.print(\"Enter the height of father in inches: \"); fatherHeight = sc.nextInt(); } if(gender == \'M\') childHeight = ((motherHeight * 13 / 12.0) + fatherHeight) / 2; else childHeight = ((fatherHeight * 12 / 13.0) + motherHeight) / 2; System.out.println(\"The height of the child is: \" + childHeight); System.out.print(\"Do you want to calculate again...(Y/N): \"); char again = sc.next().charAt(0); if(again != \'Y\') return; } } } If you need any refinements, just get back to me..