Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

6.10 Mad Lib (Individual Assignment) This is an individual Assignment. You must complete this assignment on your own. - Do not collaborate or share code

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
6.10 Mad Lib (Individual Assignment) This is an individual Assignment. You must complete this assignment on your own. - Do not collaborate or share code with other students - Do not copy and paste oade from anywhere - Do not use any resources cutside of those provided in the course materials. - Do not use any language features that have not been covered to this point in the course materials. - If you ger stuck or need help, please use only the help systems provided in this course. Required Skills Inventory - Declare a variable - Usevariables to name, store, and retrieve values - import java.util.scanner - Declare and instantiate a seanner - Use system.out.print to prompt the user for input - Use a scanner to collect user input - Store a value in a variable - Use string literals to define a string value - Retrieve a value from a variable - Output the value of a variable to the console - Use String concatenation operator to construct an expression - Use string literals and string variables and concatenation to construct string expressions - Output to console with system, out.printf - Use format specifiers to format floating point values Problem Description and Given Info White a Java program that will take the inputs listed below, and output a short story based on those inputs. Inputs 1. num-1 (an int) 2 num.2 (an int) 3. num. 3 (a double) 4. noun (a string) 5. proper name (a string) 6 verb (a string) 7. adjective.1 (a string) 8 adjective 2 (a string) These inputs will be used to output some toxt where the eden ignated_spaces> will be replaced with the corresponding input value. One day, enun_ls knouns (a) wanted to cross a bridge over a river. Onder that bridge lived a (n) codjective_ts Troll weighing chun_3s poundt, with cnum_2s eyea and hair, named Heve are tome examples of what the use should see when the program runt. Example 1 Finter a whole number 1 a3 Enter ahothnt whole thieker 1.10 Enter any number i 7.5 Mriter a houn i tres Eintet proper, name 1.8 an sint th teces in vert i ashed tinine an adfective it ateet inter mother odjectiva it havy One day, 33 tree(t) wasted to ctoss a bridge over a elver. Under that beidqe Iived a (in) green Treit veighing 1,50 peande, with 10 wyes and havy hait, named san smith. gam smith said to the tree(s) *ashice avoy. of I will hove to cat poult, Example 2. Fnter o whole nuhber i 2 Enter another whole nabet i 22 tritar any number :3000 Binter a boun i frog Britee proper hane t Aay Sones Frol1 veighing 3000.60 poundt, with 22 eyea and blue hair, naned Aey Jones. Amy Jones taid to the frog(s) "butp avay, or 1 will have to eat youl". For the given inputs. make sure that your program output looks exnctly like the exumple above fincluding spelling capitalization. punctuation, spaces, atad decinal pointe) Hints and Helpful info - There should only be one newline character in your output, and it should be at the very end of your output. - A proper name may be more that one word (for example. Bob Smat). Therefor the scanner next method will not workreliably for this input. Fiemember that scanner methods, liee next Int, nextbouble, and noxt, leaves the newhine in the input, while nexttine does not skip leading whitespace. When following next (or next int, or nextDouble) with next.tifie, an extra nextti ine is needed to get past the newine left in the input by next. Consider the following example: fyaten, out,print (*Einter age i = ) f Int age = scnt onextint () i systen-dut,ptint("Enter name i "), String fal1Nase - ochr, nextline () 2 Assume the user enters 23 for the age To do this the user must hit the 2 key, then the 3 key, then the znter key So three characters are inputted "23cl? The scanser next Int method will read in the 2 and the 3 and 23 will be stored in the variable age Howeved, the newline chancter "ell" will remain. So, when the seanner nextwine method is executed, it finds a blank line ("el) in the input and an empty string (a string value with zero characters) is stored in the variable nane. The solution is to manually extract the newline character before you try to read in the name input. We canjust call the Scanner nexti. ine method to read in the newline, and ignore it, like this: Syaten. out.print ("Enter age t ") ) int age - scnr.nextint (1) sent, nexthine ( a f /f read in and ignore the new1ine left by the previous input 5yatein.out.print. ("Enter age i ") t. int agk = aonrinextint (1) achronextline (1) 4 thad in and iqnote the newilne left by the previoun inpot syaten. but. pitint ("Fhter nane i: "if strihg fullsate = sent onbxtulne()/ - the weigte in pounds must hive 2 decimal places. - You could do much of the ouput formsting with simple string concatenation, but using syat o, out, print will make things newter and easier - This wil be much ebsier if you use muliple systes. out.pr int f statements - there must be a single newline character at the end of the output. - Noun - Pernon place, thing or ides - Verb - Expresses an action Live Rur, ump, drew, smie - Adjective - Modifies or describes a noun or pronoun Like blue, fuzry, loud If your code is not passing all the auto-grader tests - Be sure to scroll all the way through both the Your output ends with fext, and the Expected output ends with text that the auto-grader gives you. Then you will see all the places that Your output is different from the Expected output. - Do not worry about any part that comes before the "one day, "part of the output Everything starting with the "one day," and that comes after that must match exictly Need Help? Additionai help resources are avalable by cicking on the words "Need Help?" at the bottom of this page and search for helo or aska

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Statistical And Scientific Database Management International Working Conference Ssdbm Rome Italy June 21 23 1988 Proceedings Lncs 339

Authors: Maurizio Rafanelli ,John C. Klensin ,Per Svensson

1st Edition

354050575X, 978-3540505754

More Books

Students also viewed these Databases questions