# 2019 Section B Solution Two Words ```java package twowords; import java.util.Scanner; public class Main { Main() { // Scanner scan = new Scanner(System.in); // // System.out.println("Enter first word"); // String word1 = scan.nextLine(); // // System.out.println("Enter second word"); // String word2 = scan.nextLine();// System.out.println(checkWords("eat", "ate")); System.out.println(checkWords("eat", "heart")); System.out.println(checkWords("to", "position")); System.out.println(checkWords("meet", "meat")); } public String checkWords(String word1, String word2) { boolean isFormed = true; char[] chars1 = word1.toCharArray(); char[] chars2 = word2.toCharArray(); for (char c : chars1) { boolean isFound = false; int i = 0; int length = word2.length(); while (!isFound && i < length) { if (c == chars2[i]) { isFound = true; chars2[i] = '*'; } i++; } if (isFound == false) isFormed = false; } if (isFormed) return "word can be created"; else return "Word cannot be created"; } public static void main(String[] args) { // TODO Auto-generated method stub new Main(); } } ```