The solution to this problem can be modeled after the program in Figure 1.16. Modeling a solution to a problem after a problem you already know how to solve is an important problem solving technique.
You will need to use the System.out object and the println() method in your program.
Setting Up: Open up a pen a terminal window by clicking the Terminal Program icon, which looks like a monitor. Create a subdirectory in your cpsc115 named lab1. You will save all the work for this lab in that directory. Open up the KWrite text editor in a second window. This is where you will code your program.
Stepwise Refinement: Stepwise refinement is an important approach to programming and problem solving. The idea is to build your program is small stages, compiling and testing after every stage. This will help you isolate syntax and semantic errors that get introduced into the code.
Here are some suggested steps for this program.
/******************************************************* * File: NurseryRhyme.java * Author: Your name * Course and lab section: CPSC 115 Tuesday lab * Description: A program to print a nursery rhyme. *******************************************************/
$ javac NurseryRhyme.java $ java NurseryRhymeIf everything is correct, no error messages should be reported but the program won't display any output yet.
Have your work checked by the lab instructor before you
leave the lab. Print out and hand in a copy of your program.
Use the Trinity College Blackboard CourseInfo Digital
Drop Box to submit your file: Temperature.java.
NOTE: Always select the LOGOUT
option to exit CourseInfo. Closing the browser window does
Not terminate your CourseInfo session.