Skip to the content.

Java Mad Libs

import java.util.Scanner;
public class MadLibs {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.println("Welcome to Mad Libs! Let's create a funny story.");
        System.out.print("\nEnter a noun: ");
        String noun = input.nextLine();
        System.out.print("\nEnter an adjective: ");
        String adjective = input.nextLine();
        System.out.print("\nEnter a verb: ");
        String verb = input.nextLine();
        System.out.print("\nEnter an adverb: \n");
        String adverb = input.nextLine();
        System.out.println("\nHere's your story: \n");
        System.out.println("Once upon a time, there was a " + adjective + " " + noun + " who loved to " + verb + " " + adverb + ".");
        input.close();
    }
}
MadLibs.main(null);
Welcome to Mad Libs! Let's create a funny story.

Enter a noun: 
Enter an adjective: 
Enter a verb: 
Enter an adverb: 

Here's your story: 

Once upon a time, there was a big dog who loved to run slowly.