Step 2 Exercise - Using while loop:
Write a Java program (using while loop) to display 5 lines of smiley faces. The following would be the output of your program:
Note: Sample program is in the "Important Documents", Module 6 folder)
Hello:
Bye!
Hi,
I was not able to see what kind of smiley output , you are looking for! but i created a program to print a 5 smiley line (typo or text emoticons).
Below is program:
public class SmileyFaces
{
public static void main(String[] args)
{
//Array of typo/text smiley
String[] smileyArr = {":)", ":-)", ":(", ":D", ":*(" };
int i=0;
System.out.println("Hello:\n");
// while loop to print 5 smiley
while(i < smileyArr.length){
System.out.println(smileyArr[i]);
i++;
}
System.out.println("\nBye!\n");
}
}
Get Answers For Free
Most questions answered within 1 hours.