In: Computer Science
Write a Java program which is a story with blanks that will be filled in by the user’s input. Ask the user bunch of questions and then make up a story with all of the user’s answers.
Requirement
Methods
Main method
Story:
Sample output
/* The highlighted words in the story are the content of the variables*/
How many stories are you making: 2
Answer a few questions and I will make up a story for you
What is your name? Sam
What are three of your favorite Halloween characters?
Charcter 1 --> Ghost
Charcter 2--> Skeleton
Character 3--> Jack-O-Lantern
What is the spookiest place you can think of? graveyard
What is the address of the graveyard? 13000 Ghost Town
What is your favorite kind of candy? Kit Kat
How would you describe something that is very scary? dark
What is favorite number? 25
What is your favorite website? Facebook
Once upon a dark night, Sam went for a jog to the place at 13000 Ghost Town.
When Sam got there Sam screamed when Sam saw a very scary Ghost.
The Ghost was very friendly after Sam gave it a Kit Kat.
Then the Ghost introduced Sam to his friends the Skeleton and Jack-O-Lantern.
The Ghost said he had more friends if Sam wanted to meet them.
Sam gave the Ghost $5.0 to NOT bring out his other friends and then Sam ran away.
Sam went online to Facebook to message his friends about the whole thing. Bye, have a good day.
Answer a few questions and I will make up a story for you
What is your name? Jost
What are three of your favorite Halloween characters?
Charcter 1 --> Vampire
Charcter 2--> Jack-O-Lantern
Character 3--> Creepy clown
What is the spookiest place you can think of? dark jungle
What is the address of the dark jungle? 123 creepy st
What is your favorite kind of candy? sour candy
How would you describe something that is very scary? frightening
What is favorite number? 36
What is your favorite website? Discord
Once upon a frightening night, Jost went for a jog to the place at 123 creepy st.
When Jost got there Jost screamed when Jost saw a very scary Vampire.
The Vampire was very friendly after Jost gave it a sour candy.
Then the Vampire introduced Jost to his friends the Jack-O-Lantern and Creepy clown.
The Vampire said he had more friends if Jost wanted to meet them.
Jost gave the Vampire $6.0 to NOT bring out his other friends and then Jost ran away.
Jost went online to Discord to message his friends about the whole thing. Bye, Have a good day
package practice;
import java.util.Scanner;
public class first {
public static void main(String[] args) {
System.out.println("How many Stories are you making?");
//intializing scanner class object
Scanner sc = new Scanner(System.in);
//total number of stories user wants to create
int numOfStories = sc.nextInt();
for(int i = 0; i<numOfStories; i++){
//calling story function and passing scanner object as parameter
story(sc);
}
}
// static function
public static void story(Scanner sc){
System.out.println("Answer a few Question and we will frame a story for you...");
System.out.println("What is your name");
sc.nextLine();
String userName = sc.nextLine();
System.out.println("What is your gender (M/F)?");
String gender = sc.nextLine();
System.out.println("What is the pin code of your area?");
int pinCode = sc.nextInt();
sc.nextLine();
System.out.println("What is the name of your native village?");
String villageName = sc.nextLine();
System.out.println("Which is your fathers name ?");
String farthersName = sc.nextLine();
System.out.println("What is your height in feet?");
double height = sc.nextDouble();
System.out.println("Which social media website you use the most ?");
sc.nextLine();
String socialMedia = sc.nextLine();
System.out.println("Choose any number between 1-100 ?");
int money = sc.nextInt();
sc.nextLine();
System.out.println("Which is your favourite colour ?");
String fvrtColor = sc.nextLine();
sc.nextLine();
// string class function used are .equals and .concat
// math class power(x,y) is used
if(gender.equals("M")){
System.out.println("A boy named " + userName +" is found missing since last thrusday. As per the data given by this father Mr. "+ farthersName + ". He has left his house last thrusday at 9:00 AM ");
System.out.println("from his native village "+villageName + ". His height is " + height + " and he is wearnig white color t-shirt and "+fvrtColor + " jeans and is Addicted to " + socialMedia + ".");
System.out.println("Whosever found this guy can report to his father at " + villageName.concat(" " + pinCode) + " and he will be awarded with " + Math.pow(money, 2) + " rupess and a dairy milk choclate");
System.out.println("Please help us in finding this charming and intelligent guy.");
}
else{
System.out.println("A girl named " + userName + " is found missing since last thrusday. As per the data given by this father Mr. "+ farthersName + ". she has left his house last thrusday at 9:00 AM from his native village i.e "+villageName);
System.out.println("from his native village "+villageName + ". His height is " + height + " and she is wearnig white color top and "+fvrtColor + " jeans and is Addicted to " + socialMedia + ".");
System.out.println("Whosever found this guy can report to her father at " + villageName.concat(" " + pinCode) + " and he will be awarded with " + Math.pow(money, 2) + " rupess and a dairy milk choclate");
System.out.println("Please help us in finding this charming and intelligent girl.");
}
}
}
press enter after entering all details to create the sotry.
you can customise the story if you find something intresting. Comment in case you have any doubt.