import java.io.*; //----------------------------------------------------------------- // CS100 P1 Q3 // // This program prompts the user for three words : an adjective, a // past tense verb, and a noun, in that order, then fills in the // blanks in the following sentence and prints the resulting sentence. // // The __ professor __ my __, and I've never recovered. // // Author : Wei Tsang Ooi (weitsang@cs.cornell.edu) // Date : 5 July 1999 //----------------------------------------------------------------- class MadLib { //------------------------------------------------------------- // intro // // This method prints an introduction message //------------------------------------------------------------- private static void intro() { String msg = "This is a Mad-Lib game. I will prompt " + "you for three words.\n"; System.out.print(msg); } //------------------------------------------------------------- // getInput // // input : a prompt message // return : the value input by user // // This method prompt the user for input, and return the value // input by the user. //------------------------------------------------------------- private static String getInput(String msg) throws IOException { BufferedReader stdin; stdin = new BufferedReader(new InputStreamReader(System.in)); System.out.print(msg); return stdin.readLine(); } //------------------------------------------------------------- // printOutput // // input : a temperature in Fahrenheit // return : none // // Output the temperature on the screen. //------------------------------------------------------------- private static void printOutput (String adj, String verb, String noun) { String output = "\nThe " + adj + " Professor " + verb + " my " + noun + ", and I've never recovered.\n"; System.out.println(output); } public static void main(String[] args) throws IOException { intro(); String adj = getInput("Enter an adjective : "); String verb = getInput("Enter a verb (past tense) : "); String noun = getInput("Enter a noun : "); printOutput(adj, verb, noun); } }