Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.90 KB | None | 0 0
  1. import java.util.Scanner;
  2. //Importing the Scanner.
  3. public class main {
  4.     static Scanner input = new Scanner(System.in);
  5. //Making a scanner.
  6.     String name;
  7.     String noun;
  8.     String verb;
  9.     static int int1;
  10.     static double double1;
  11. //Making all my variables for use later on
  12.     public static void main(String[] args) {
  13.         // TODO Auto-generated method stub
  14.         System.out.println("We're gonna put together a quick story, and you're gonna help out. \n What is your name?");
  15.         String name = input.nextLine();
  16.         System.out.println("Please enter a noun.");
  17.         String noun = input.nextLine();
  18.         System.out.println("Now enter a verb.");
  19.         String verb = input.nextLine();
  20.         System.out.println("Now a whole number.");
  21.         //Getting all the data we need and writing it to the strings and variables.
  22.         if (input.hasNextInt()) {
  23.             int1 = input.nextInt();
  24.             }
  25.         else {
  26.             //Make things not break.
  27.         }
  28.         input.nextLine();
  29.         //verifying that the user did what they were supposed to or didn't enter a number too large, and calling nextLine().
  30.         System.out.println("Now enter a number, real or decimal.");
  31.         if (input.hasNextDouble()) {
  32.             double1 = input.nextDouble();
  33.         }
  34.         else {
  35.             //Make stuff not break again.
  36.         }
  37.         input.nextLine();
  38.         //doing it again.
  39.         String story = "One stormy evening, " + name + " suddenly burst out of a hotel, " + noun + " in hand, ";
  40.         story += "screaming at the top of their lungs while " + verb + "ing the " + noun + " and spinning in circles until " + name + " fell over.\n";
  41.         story += "Then " + name + " took out their wallet and threw exactly " + int1 + " dollars at an oncoming car. ";
  42.         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";
  43.         story += name + " would later spend " + double1 + " days in jail for disorderly conduct.";
  44.         System.out.println(story);
  45.         }
  46.         //telling a story
  47.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement