In this program you will learn to read strings from the keyboard and write them to the monitor. Consider the following output (excerpts from a book by Martin and Carle) from the program called sounds:
I hear a lion roaring in my ear. I hear a hippopotamus snorting in my ear. I hear a elephant trumpeting in my ear.Write a program that produces 3 verses of this book interactively with the user. Running your program should produce a screen display similar to that shown below. User inputs are itialized.
bear, bear, what do you hear? Enter an animal and its noise: lion roaring I hear a lion roaring in my ear. lion, lion, what do you hear? Enter an animal and its noise: hippopotamus snorting I hear a hippopotamus snorting in my ear. hippopotamus, hippopotamus, what do you hear? Enter an animal and its noise: elephant trumpeting I hear a elephant trumpeting in my ear.Note that the animal making noise on the second line of a verse should be the same as the first animal on the first line of the next verse.
You should use the Keyboard class (provided by the authors' of your text) to make the job of reading strings from the keyboard easy. To use this class, follow these brief instructions:
import cs1.Keyboard;Remember that capitilization is important. There are examples of programs that use the Keyboard class in Figures 2.10, 2.11, and 2.12 of your text.
Write the program described in problem 2.6 on page 105 of your text. This program will help you learn to use integer division and the modulus (or, as the book calls it the remainder) operator.
Hint: If a variable named seconds initially stores the value 511:
seconds % 60
number = seconds / 60;
Again, you will need to use the Keyboard class to make the job of reading the user input (i.e.,the number of seconds) easy. Follow the instructions given above for using that class in this program, with one exception. In step 1, the name of the java source code file for this program must be Time.
Both programs written for this assignment must be turned in by transferring the respective java source code files to your ftp directory for this class. For each program, only the source code file (i.e., Sounds.java, and Time.java) should be turned in and the files must have exactly those names. You were shown how to transfer files to your class ftp directory in lab 1, here is a quick refresher.