Question

You will create your own silly story based on information provided by the user. For example,...

You will create your own silly story based on information provided by the user. For example, the parts in bold were entered by the user. For ideas see: Mad Libs.

My Silly Story
name: Frank Zhang
whole number: 345
body part: stomach
noun: cup
floating point number: 1.23
clothing article: hat
destination: Colorado
goal: degree

The resulting story is:

Congratulations!

Today is your 345 day.

You're off to Colorado!

You're off and away!

You have brains in your stomach, You have feet in your hat.

You can steer yourself any direction you choose.

You're on your own with $1.23. And you know what you know.

And YOU are the cup who'll decide where to go.

be your name Frank Zhang or Bixby or Bray

or Mordecai Ali Van Allen O'Shea,

You're off to Colorado!

Today is your day!

Your degree is waiting. So...get on your way!

Based on Dr. Seuss "Oh, the Places You'll Go!" and adapted by Jim Williams

Requirements:

  • Your main method should contain all input code (e.g., Scanner instance) and have 8 user prompts inputting values with nextInt(), nextDouble(), next() and nextLine().
  • All output code (e.g., print statements) must be in the main method as well.
  • The prepareStory method takes the arguments passed in and prepares the entire story, using all the 8 parameters and returning one long String.
  • The names of the parameters for the method should be changed to better reflect their contents.
  • You do not need to use the above story. Get creative and come up with your own Mad Lib!
  • Your story must contain your name as you entered it in the file header comments. It should be a string literal and not passed in as a parameter.
  • The method stub for prepareStory is

/**

* Returns a String that is a story containing the 8 arguments passed in. Also, your story must include

* the author's name (your name) within it using a string literal (don't pass as a parameter).Your name must match the name

* within the File Header Comment.

*

* There are no input or output statements within this method. All input and

* output is done in the main method and the user must be prompted for all the arguments.

*

* Note: Your method must have the name 'prepareStory', must have 8 parameters with the same data types shown and * in the same order. You must change the parameter names to match values in your story. For example, you may want

* to prompt for a verb, and store in a String parameter you name verb, or an adjective and store in a String param you

* name adjective.

*

* @param num1 int 1

* @param str1 String 1

* @param str2 String 2

* @param str3 String 3

* @param str4 String 4

* @param dbl1 double 1

* @param str5 String 5

* @param str6 String 6

* @return A story containing the 8 arguments and includes the program author's name.

*/

public static String prepareStory(int num1, String str1, String str2, String str3, String str4, double dbl1, String str5, String str6) {

//FILL IN BODY

}

MySillyStory.java

import java.util.Scanner;

public class MySillyStory {
  
//add prepareStory method


   public static void main(String[] args) {
//prompt the user
//pass the responses to the prepareStory method
//print out the story returned from prepareStory
   }
}

0 0
Add a comment Improve this question Transcribed image text
Answer #1

HI there,

Following is the code,If you still have any queries,feel free to ask in the comments box.

Code:

import java.util.Scanner;

public class MySillyStory {

//prepareStory method
   public static String prepareStory(int number, String name, String part, String noun, String clothing, double floatnum, String destination, String goal) {
       //combining all into a single string,\n is a new line character to change the line
       String s="Congratulations!\n"+

                  "Today is your "+number+" day.\n"+

                   "You're off to "+destination+"!\n"+

                    "You're off and away!\n"+

                    "You have brains in your "+part +", You have feet in your "+clothing+".\n"+

                     "You can steer yourself any direction you choose.\n"+

                     "You're on your own with $"+floatnum+". And you know what you know.\n"+

                      "And YOU are the "+noun+" who'll decide where to go.\n"+

                       "be your name "+name+" or Bixby or Bray\n"+

                       "or Mordecai Ali Van Allen O'Shea,\n"+

                         "You're off to "+destination+"!\n"+

                       "Today is your day!\n"+

                        "Your "+goal+" is waiting. So...get on your way!\n"+

                      "Based on Dr. Seuss 'Oh, the Places You'll Go!' and adapted by Jim Williams";
     return s;//returning the string
      

       }


   public static void main(String[] args) {
//prompt the user
//pass the responses to the prepareStory method
//print out the story returned from prepareStory
       Scanner sc=new Scanner(System.in);
       String name;
       int number;
     
       String part;
       String noun;
       double floatnum;
       String clothing;
       String destination;
       String goal;
       //accepting values
       System.out.println("name: ");
       name=sc.nextLine();
     
       System.out.println("whole number: ");
       number=sc.nextInt();
       System.out.println("body part: ");
       part=sc.next();
       System.out.println("noun: ");
       noun=sc.next();
     
     
       System.out.println("floating point number: ");
       floatnum=sc.nextDouble();
       System.out.println("clothing article: ");
       clothing=sc.next();
       System.out.println("destination: ");
       destination=sc.next();
       System.out.println("goal: ");
       goal=sc.next();
       //passing and printing the string returned
       System.out.println(prepareStory(number,name,part,noun,clothing,floatnum,destination,goal));
     
     
   }
}

Output:

name:
John James
whole number:
123
body part:
head
noun:
cup
floating point number:
32.2
clothing article:
jeans
destination:
Toranto
goal:
degree
Congratulations!
Today is your 123 day.
You're off to Toranto!
You're off and away!
You have brains in your head, You have feet in your jeans.
You can steer yourself any direction you choose.
You're on your own with $32.2. And you know what you know.
And YOU are the cup who'll decide where to go.
be your name John James or Bixby or Bray
or Mordecai Ali Van Allen O'Shea,
You're off to Toranto!
Today is your day!
Your degree is waiting. So...get on your way!
Based on Dr. Seuss 'Oh, the Places You'll Go!' and adapted by Jim Williams

Add a comment
Know the answer?
Add Answer to:
You will create your own silly story based on information provided by the user. For example,...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • SCREENSHOTS ONLY PLEASE!!! DON'T POST ACTUAL CODE PLEASE LEAVE A SCREENSHOT ONLY! ACTUAL TEXT IS NOT NEEDED!!! myst...

    SCREENSHOTS ONLY PLEASE!!! DON'T POST ACTUAL CODE PLEASE LEAVE A SCREENSHOT ONLY! ACTUAL TEXT IS NOT NEEDED!!! mystring.h: //File: mystring1.h // ================ // Interface file for user-defined String class. #ifndef _MYSTRING_H #define _MYSTRING_H #include<iostream> #include <cstring> // for strlen(), etc. using namespace std; #define MAX_STR_LENGTH 200 class String { public: String(); String(const char s[]); // a conversion constructor void append(const String &str); // Relational operators bool operator ==(const String &str) const; bool operator !=(const String &str) const; bool operator >(const...

  • #include <iostream> //write preprocessor file for string datatype here using namespace std; //write your function prototypes...

    #include <iostream> //write preprocessor file for string datatype here using namespace std; //write your function prototypes here: int main() {     cout << "Welcome to Mad Lib.\n\n";     cout << "Answer the following questions to help create a new story.\n";     string name = askText("Please enter a name: ");          string noun = askText("Please enter a plural noun: ");          int number = askNumber("Please enter a number: ");          string bodyPart = askText("Please enter a body part: ");          string...

  • Create a class named Module2. You should submit your source code file (Module2.java). The Module2 class...

    Create a class named Module2. You should submit your source code file (Module2.java). The Module2 class should contain the following data fields and methods (note that all data and methods are for objects unless specified as being for the entire class) Data fields: A String object named firstName A String object named middleName A String object name lastName Methods: A Module2 constructor method that accepts no parameters and initializes the data fields from 1) to empty Strings (e.g., firstName =...

  • Write a Python program to create userids: You work for a small company that keeps the...

    Write a Python program to create userids: You work for a small company that keeps the following information about its clients: • first name • last name • a user code assigned by your company. The information is stored in a file clients.txt with the information for each client on one line (last name first), with commas between the parts. In the clients.txt file is: Jones, Sally,00345 Lin,Nenya,00548 Fule,A,00000 Your job is to create a program assign usernames for a...

  • User Profiles Write a program that reads in a series of customer information -- including name,...

    User Profiles Write a program that reads in a series of customer information -- including name, gender, phone, email and password -- from a file and stores the information in an ArrayList of User objects. Once the information has been stored, the program should welcome a user and prompt him or her for an email and password The program should then use a linearSearch method to determine whether the user whose name and password entered match those of any of...

  • Problem 1 1. In the src → edu.neiu.p2 → problem1 directory, create a Java class called...

    Problem 1 1. In the src → edu.neiu.p2 → problem1 directory, create a Java class called HW4P1 and add the following: • The main method. Leave the main method empty for now. • Create a method named xyzPeriod that takes a String as a parameter and returns a boolean. • Return true if the String parameter contains the sequential characters xyz, and false otherwise. However, a period is never allowed to immediately precede (i.e. come before) the sequential characters xyz....

  • create a new Java application called "CheckString" (without the quotation marks) according to the following guidelines....

    create a new Java application called "CheckString" (without the quotation marks) according to the following guidelines. ** Each method below, including main, should handle (catch) any Exceptions that are thrown. ** ** If an Exception is thrown and caught, print the Exception's message to the command line. ** Write a complete Java method called checkWord that takes a String parameter called word, returns nothing, and is declared to throw an Exception of type Exception. In the method, check if the...

  • Within DrJava, create a class called StudentQuizScores and do the following using a do-while loop. 1....

    Within DrJava, create a class called StudentQuizScores and do the following using a do-while loop. 1. You program will read in a student’s first name. The same will be done for the student’s last name. Your program will use respective methods (described below) to accomplish this. 2. Your program will then read in three quiz scores, respectively. This should be done by using the same method three times. This method is described below. 3. Your program will then calculate the...

  • +array:int[] This is provided to facilitate testing and grading. Use it as your internal array. +size:int...

    +array:int[] This is provided to facilitate testing and grading. Use it as your internal array. +size:int i.e. after items are added to the array, or deleted from it. One default constructor (receives nothing and initializes an array of size 0), and another constructor that receives an int[] and initializes the internal array with the input parameter. both of the constructors exist and work fine. In initializing the internal array with the input parameter, you should make a copy of the...

  • Copy the program AmusementRide.java to your computer and add your own class that extends class AmusementRide....

    Copy the program AmusementRide.java to your computer and add your own class that extends class AmusementRide. Note: AmusementRide.java contains two classes (class FerrisWheel and class RollerCoaster) that provide examples for the class you must create. Your class must include the following. Implementations for all of the abstract methods defined in abstract class AmusementRide. At least one static class variable and at least one instance variable that are not defined in abstract class AmusementRide. Override the inherited repair() method following the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT