Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  MadLibsStory
Language: JAVA
Code:
import java.util.Random;
import java.util.Scanner;
public class MadLibsStory {
     public static void main(String[]args){
          String baseStory = "The gull stared into the two beady, gold-rimmed eyes of its foe, its own expression one of intense disgust. It dove forward, beak slicing the air with pinpoint precision - but the blow, meant to pierce white feathers, clinked loudly and slid aside at the last moment. The gull stabbed again and again, infuriated by the realization that its target was doing the same, but each time its attacks were repelled by an unseen force. Despite its bravery the gull feared it might never succeed, and was only heartened by the fact that its hated enemy looked just as crestfallen.";
 
          Scanner reader = new Scanner(System.in);
 
          System.out.print("Noun: ");
          String noun1 = reader.next();
 
          Random randomizedNumber = new Random();
          int random1 = randomizedNumber.nextInt();
          String number1 = Integer.toString(random1);
 
 
          System.out.print("Adjective: ");
          String adj1 = reader.next();
 
          System.out.print("Noun: ");
          String noun2 = reader.next();
 
          System.out.print("Adjective: ");
          String adj2 = reader.next();
 
          System.out.print("Verb: ");
          String verb1 = reader.next();
 
          System.out.print("Adjective: ");
          String adj3 = reader.next();
 
          System.out.print("Verb: ");
          String verb2 = reader.next();
 
          System.out.print("Color: ");
          String color1 = reader.next();
 
          System.out.print("Plural Noun: ");
          String pluralNoun1 = reader.next();
 
          System.out.print("Past Tense Verb: ");
          String pastVerb1 = reader.next();
 
          System.out.print("Verb: ");
          String verb3 = reader.next();
 
          System.out.print("Adjective: ");
          String adj4 = reader.next();
 
          System.out.print("Plural Noun: ");
          String pluralNoun2 = reader.next();
 
          System.out.print("Past Tense Verb: ");
          String pastVerb2 = reader.next();
 
          System.out.print("Noun: ");
          String noun3 = reader.next();
 
 
 
          System.out.print(baseStory.replace("gull",noun1).replace("two",number1).replace("beady", adj1).replace("foe",noun2).replace("disgust",adj2).replace("dove",verb1).replace("pinpoint",adj3).replace("pierce",verb2).replace("white",color1).replace("feathers",pluralNoun1).replace("clinked",pastVerb1).replace("slid",verb3).replace("infuriated",adj4).replace("attacks",pluralNoun2).replace("repelled", pastVerb2).replace("force",noun3));
 
          reader.close();
     }
}
Comments: