123k views
2 votes
Mad Libs are activities that have a person provide various words, which are then used to complete a short story in unexpected (and hopefully funny) ways. Complete the program to read the needed values from input, that the existing output statement(s) can use to output a short story. Ex: If the input is "Eric Chipotle 12 cars" (excluding the quotes), the output is:

User Vadimchin
by
5.6k points

1 Answer

3 votes

Answer:

The code is below. The output is "Eric went to Chipotle to buy 12 different types of Cars"

Step-by-step explanation:

import java.util.scanner;

public class labprogram {

public static void main (string [ ] args) {

scanner scnr = new scanner (system.in) ;

string firstname;

string genericlocation;

int wholenumber;

string pluralNoun;

firstName = scnr.next();

genericLocation = scnr.next();

wholeNumner = scnr.nextInt();

pluralNoun = scnr.nextLine();

system.output.println(firstname + " went to " + genericlocation + " to buy " + wholenumber + " different types of " + pluralnoun + " . ");

}

}

User Hossein Hadi
by
6.0k points