if Y the result should be YELLOW, if R the result should be RED, if W the result should be WHITE, if V the result should be VIOLET, if P the result should be PINK, if the user will input none of those letter ten the output should be "NO COLOR AVAILABLE!"
Code:
Here's the code:
package color; import java.util.Scanner; public class Color { static Scanner console=new Scanner(System.in); public static void main(String[] args) { String input; char letter; System.out.println("Enter a letter:"); input=console.next(); letter=input.charAt(0); switch (letter){ case'y':case'Y':System.out.println("Yellow");break; case'r':case'R':System.out.println("Red");break; case'w':case'W':System.out.println("White");break; case'v':case'V':System.out.println("Violet");break; case'p':case'P':System.out.println("Pink");break; default:System.out.println("NO COLOR AVAILABLE!");break; } } }
0 comments :
Post a Comment