You could also create an array of strings, where indices 0 and 5 are asterisks and the indices in between are lines in the poem. Then just run through a loop to print each of the lines. I guess I dont' know for sure if your instructor would count that as one call to System.out.println, but it would be one line of code.
On 5/30/2010 8:00 PM, Dave wrote:
You can write the calls to System.out.println in a single statement if you simply concatenate the strings for each individual call to System.out.println using the "+" operator. For example: string s1, s2, s3, s4; System.out.println(s1 + "\n" + s2 + "\n" + s3 + "\n" + s4); hth, David On 5/30/10, Gilbert Neiva<gneiva@xxxxxxx> wrote:I'm trying to write a program in Eclipse that quotes four lines from a poem, but I'm suppose to write the four lines in one output statement. I'm also suppose to put asterisks around the four lined quote. How would I do this all in one statement? The program I wrote is below. // Application HatchesTheEgg // This application will write // four lines from // Dr. Seuss's Horton's // Hatches the Egg import java.io.*; // Imports the java.io package public class HatchesTheEgg { public static void main(String[] args) { final String phrase1 = "I meant"; final String phrase2 = "I said"; final String phrase3 = "an elephant's faithful"; final String phrase4 = "one hundred percent"; final String stars = "***************************"; System.out.println(stars); System.out.println("* "+phrase1+" what "+phrase2+" *"); System.out.println("* and "+phrase2+" what "+phrase1+" *"); System.out.println("* "+phrase3+" *"); System.out.println("* "+phrase4+" *"); System.out.print(stars); } } Gilbert Neiva__________ View the list's information and change your settings at //www.freelists.org/list/programmingblind
__________View the list's information and change your settings at //www.freelists.org/list/programmingblind