Write a program a java to input a choice of character amd print the seven colour sproctrom VIBGYOR
VIBGYOR Color Checker
Code:
import java.util.Scanner;
public class VIBGYOR {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter a character (V/I/B/G/Y/O/R): ");
char ch = sc.next().toUpperCase().charAt(0);
switch(ch){
case 'V':
System.out.println("V - Violet");
break;
case 'I':
System.out.println("I - Indigo");
break;
case 'B':
System.out.println("B - Blue");
break;
case 'G':
System.out.println("G - Green");
break;
case 'Y':
System.out.println("Y - Yellow");
break;
case 'O':
System.out.println("O - Orange");
break;
case 'R':
System.out.println("R - Red");
break;
default:
System.out.println("Invalid Input! Please enter any one from V I B G Y O R.");
}
sc.close();
}
}