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
  • /* * CPS150_Lab10.java */ import java.io.*; import java.util.*; /** * CPS 150, Fall 2018 semester *...

    /* * CPS150_Lab10.java */ import java.io.*; import java.util.*; /** * CPS 150, Fall 2018 semester * * Section N1 * * Lab Project 13: Comparing Java Strings * * @author *** Replace with your name *** */ public class CPS150_Lab13 { static final Scanner KBD = new Scanner(System.in); static final PrintStream OUT = System.out; // TO DO: Implement each of the following 4 methods, // using the String compareTo method: /* * lessThan(String, String) -> boolean * * method is...

  • 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...

  • Note that the main function that I have provided does use <string.h> as it constructs test...

    Note that the main function that I have provided does use <string.h> as it constructs test strings to pass to your functions. However, your solutions for the 5 functions below may not use any of the built-in C string functions from the <string.h> library. Write a function called strcmp373. This function is passed two parameters, both of which are C strings. You should use array syntax when writing this function; that is, you may use [ ], but not *...

  • 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 =...

  • 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....

  • CSC Hw Problems. Any help is appreciated I dont know where to start let alone what...

    CSC Hw Problems. Any help is appreciated I dont know where to start let alone what the answers are. Your assignment is to write your own version of some of the functions in the built-in <string.h> C library. As you write these functions, keep in mind that a string in C is represented as a char array, with the '\0' character at the end of the string. Therefore, when a string is passed as a parameter, the length of the...

  • 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...

  • This program will take the classic tongue-twister "Peter Piper picked a peck of pickled peppers." and...

    This program will take the classic tongue-twister "Peter Piper picked a peck of pickled peppers." and generate a tongue twister phrase based on user input for a last name, a unit of measurement and a vegetable. For all three cases, the user input may be multiple words. Once read, the user input will be modified to fit the following rules: last name: No leading or trailing whitespace; the first character will be upper case and the rest lower case. unit...

  • 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...

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