6.) Scenario – You are playing a guessing game with your little cousin. She wants you to guess her favorite color. Create a program using the While loop. Below is a code I'm writing but having trouble with the while loop.
package loopscenario;
import java.util.Scanner;
import java.util.Random;
/**
*
* @author macbook
*/
public class LoopScenario6 {
public static void main(String[] args)
{
String blue = null;
String yellow = null ;
String red = null;
String pink = "pink";
String favoriteColor = null;
Scanner keyboard = new Scanner(System.in);
Random randomNumber = new Random();
Random aRan = new Random();
while (!favoriteColor.equalsIgnoreCase(pink))
if (favoriteColor.equalsIgnoreCase(blue))
{
System.out.println("Wrong color. Please try again.");
}
else if( favoriteColor.equalsIgnoreCase(yellow))
{
System.out.println("Wrong color. Please try again.");
}
else if ( favoriteColor.equalsIgnoreCase(red))
{
System.out.println("Wrong color. Please try again.");
}
else
{
System.out.println("Yes!");
}
}
}