Mindtap Programming, 1 Term (6 Months) Printed Access Card For Farrell's Java Programming, 9th
Mindtap Programming, 1 Term (6 Months) Printed Access Card For Farrell's Java Programming, 9th
9th Edition
ISBN: 9781337397117
Author: FARRELL, Joyce
Publisher: Cengage Learning
bartleby

Videos

Expert Solution & Answer
100%
Book Icon
Chapter 2, Problem 1GZ

Explanation of Solution

Program code:

MadLib.java

//import the required packages

import java.io.*;

//define a class MadLib

class MadLib

{

//define a method intro()

private static void intro()

{

//create a string variable and initialize it

String msg = "This is a Mad-Lib game. I will prompt " +

"you for five words.\n";

//print the string

System.out.print(msg);

}

//define a method getInput()

private static String getInput(String msg) throws IOException

{

//create the object of BufferReader

BufferedReader stdin;

//initialize the object

stdin = new BufferedReader(new InputStreamReader(System.in));

//print the string msg

System.out.print(msg);

//return the line readed

return stdin.readLine();

}

//define a method printOutput

private static void printOutput (String noun1, String adverb, String noun2, String pronoun, String adj)

{

//create a string output and set the value

String output = "\nThree blind " + noun1 + ", \nThree blind " + noun1 + ", \nsee " + adverb +

     " they run!" + "\nsee " + adverb + " they run!\nThey all ran after the farmer's " + noun2 +

      "\nWho cut off their tails,\nWith a carving knife.\nDid you ever see " +

        pronoun + " a thing in your life,\nAs three " + adj + " mice.";

//print output

System.out.println(output);

}

//define a main() method

public static void main(String[] args) throws IOException

{

//call the method intro()

intro();

//get the value for noun1

String noun1 = getInput("Enter a noun : ");

//get the value for adverb

String adverb = getInput("Enter a adverb : ");

//get the value for noun2

String noun2 = getInput("Enter a another noun : ");

//get the value for pronoun

String pronoun = getInput("Enter a pronoun : ");

//get the value for adj

String adj = getInput("Enter an adjective : ");

//print the accepted values

printOutput(noun1, adverb, noun2, pronoun, adj);

}

}

Explanation:

The above snippet of code is used get the noun, adverb, pronoun and adjective from the user and creates the sentences using it...

Blurred answer
Students have asked these similar questions
This is a question that I have and would like someone who has experiences with scene graphs and entity component systems to answer.For context, I am currently implementing a game engine and currently I am debating on our current design.Our current design is we have a singular game component class that every component inherits from. Where we have components like SpriteRendererComponent, Mehs Component, etc. They inherit from this GameComponent class. The point of this is being able to have O(1) access to the scene to being able to modify components to attach more components with the idea of accessing those components to specific scene objects in a scene.Now, my question is what kinds of caveauts can this cause in terms of cache coherence? I am well aware that yes its O(1) and that is great but cache coherence is going to be really bad, but would like to know more explicit details and real-life examples such as write in RAM examples on how this is bad. A follow-up question that is part…
Q4: Consider the following MAILORDER relational schema describing the data for a mail order company. (Choose five only). PARTS(Pno, Pname, Qoh, Price, Olevel) CUSTOMERS(Cno, Cname, Street, Zip, Phone) EMPLOYEES(Eno, Ename, Zip, Hdate) ZIP CODES(Zip, City) ORDERS(Ono, Cno, Eno, Received, Shipped) ODETAILS(Ono, Pno, Qty) (10 Marks) I want a detailed explanation to understand the mechanism how it is Qoh stands for quantity on hand: the other attribute names are self-explanatory. Specify and execute the following queries using the RA interpreter on the MAILORDER database schema. a. Retrieve the names of parts that cost less than $20.00. b. Retrieve the names and cities of employees who have taken orders for parts costing more than $50.00. c. Retrieve the pairs of customer number values of customers who live in the same ZIP Code. d. Retrieve the names of customers who have ordered parts from employees living in Wichita. e. Retrieve the names of customers who have ordered parts costing less…
Q4: Consider the following MAILORDER relational schema describing the data for a mail order company. (Choose five only). (10 Marks) PARTS(Pno, Pname, Qoh, Price, Olevel) CUSTOMERS(Cno, Cname, Street, Zip, Phone) EMPLOYEES(Eno, Ename, Zip, Hdate) ZIP CODES(Zip, City) ORDERS(Ono, Cno, Eno, Received, Shipped) ODETAILS(Ono, Pno, Qty) Qoh stands for quantity on hand: the other attribute names are self-explanatory. Specify and execute the following queries using the RA interpreter on the MAILORDER database schema. a. Retrieve the names of parts that cost less than $20.00. b. Retrieve the names and cities of employees who have taken orders for parts costing more than $50.00. c. Retrieve the pairs of customer number values of customers who live in the same ZIP Code. d. Retrieve the names of customers who have ordered parts from employees living in Wichita. e. Retrieve the names of customers who have ordered parts costing less than$20.00. f. Retrieve the names of customers who have not placed…
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Memory Management Tutorial in Java | Java Stack vs Heap | Java Training | Edureka; Author: edureka!;https://www.youtube.com/watch?v=fM8yj93X80s;License: Standard YouTube License, CC-BY