// Helene Martin, CSE 142 // Uses a super secret algorithm to suggest baby names. import java.util.*; public class BabyNamer { public static void main(String[] args) { Scanner s = new Scanner(System.in); System.out.print("Parent 1 first name? "); String name1 = s.next(); System.out.print("Parent 2 first name? "); String name2 = s.next(); System.out.print("Child Gender? "); String gender = s.next(); String halfName1 = halfName(name1); String halfName2 = halfName(name2); // to do comparisons that ignore case, force // gender to lower case gender = gender.toLowerCase(); if (gender.startsWith("f")) { System.out.println(halfName2 + halfName1); } else if (gender.startsWith("m")) { System.out.println(halfName1 + halfName2); } else { System.out.println("BAD USER: gender should start with f or m."); } } // Given a string, split it in half and return it as uppercase. public static String halfName(String str) { String half = str.substring(0, str.length() / 2); return half.toUpperCase(); } }