Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- //Importing the Scanner.
- public class main {
- static Scanner input = new Scanner(System.in);
- //Making a scanner.
- String name;
- String noun;
- String verb;
- static int int1;
- static double double1;
- //Making all my variables for use later on
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- System.out.println("We're gonna put together a quick story, and you're gonna help out. \n What is your name?");
- String name = input.nextLine();
- System.out.println("Please enter a noun.");
- String noun = input.nextLine();
- System.out.println("Now enter a verb.");
- String verb = input.nextLine();
- System.out.println("Now a whole number.");
- //Getting all the data we need and writing it to the strings and variables.
- if (input.hasNextInt()) {
- int1 = input.nextInt();
- }
- else {
- //Make things not break.
- }
- input.nextLine();
- //verifying that the user did what they were supposed to or didn't enter a number too large, and calling nextLine().
- System.out.println("Now enter a number, real or decimal.");
- if (input.hasNextDouble()) {
- double1 = input.nextDouble();
- }
- else {
- //Make stuff not break again.
- }
- input.nextLine();
- //doing it again.
- String story = "One stormy evening, " + name + " suddenly burst out of a hotel, " + noun + " in hand, ";
- story += "screaming at the top of their lungs while " + verb + "ing the " + noun + " and spinning in circles until " + name + " fell over.\n";
- story += "Then " + name + " took out their wallet and threw exactly " + int1 + " dollars at an oncoming car. ";
- story += "A cop who was in the lane next to " + name + " jumped out of his car and arrested " + name + ", handcuffed them, and took him to the station. \n";
- story += name + " would later spend " + double1 + " days in jail for disorderly conduct.";
- System.out.println(story);
- }
- //telling a story
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement