Skip to content

PRO TIP Block youtube.com at the DNS level — Pi-hole, NextDNS or your hosts file — but allow youtube-nocookie.com and i.ytimg.com. These tutorials keep playing; the rabbit hole does not.

Learning without distractions

Let’s code a mad libs game with Java! 📖

64.8K views on YouTube

#java #javatutorial #javacourse

import java.util.Scanner;

public class Main {
public static void main(String[] args) {

// MAD LIBS GAME

Scanner scanner = new Scanner(System.in);

String adjective1;
String noun1;
String adjective2;
String verb1;
String adjective3;

System.out.print(“Enter an adjective (description): “);
adjective1 = scanner.nextLine();
System.out.print(“Enter a noun (animal or person): “);
noun1 = scanner.nextLine();
System.out.print(“Enter an adjective (description): “);
adjective2 = scanner.nextLine();
System.out.print(“Enter a verb ending with -ing (action): “);
verb1 = scanner.nextLine();
System.out.print(“Enter an adjective (description): “);
adjective3 = scanner.nextLine();

System.out.println(“\nToday I went to a ” + adjective1 + ” zoo.”);
System.out.println(“In an exhibit, I saw a ” + noun1 + “.”);
System.out.println(noun1 + ” was ” + adjective2 + ” and ” + verb1 + “!”);
System.out.println(“I was ” + adjective3 + “!”);

scanner.close();
}
}