Write a program to display the colour in a rainbow switch statement
Answers
Display Color Name from VIBGYOR Letters using Switch Case and IF – C
This is a simple c program to print name of color according the given letter from VIBGYOR, the color of rainbow. This program is to learn the working of Switch Case statement.
Answer:
import java.util.Scanner;
class PAGE_Rainbow
{
public static void main (String arg[])
{
Scanner in = new Scanner(System.in);
int op;
System.out.println("1-V");
System.out.println("2-I");
System.out.println("3-B");
System.out.println("4-G");
System.out.println("5-Y");
System.out.println("6-O");
System.out.println("7-R");
System.out.println("ENTER YOUR CHOICE");
op=in.nextInt();
switch(op)
{
case 1:
System.out.println("VOILET");
break;
case 2:
System.out.println("INDIGO");
break;
case 3:
System.out.println("BLUE");
break;
case 4:
System.out.println("GREEN");
break;
case 5:
System.out.println("YELLOW");
break;
case 6:
System.out.println("ORANGE");
break;
case 7:
System.out.println("RED");
break;
default:
System.out.println("invalid option");
}
}
}
Explanation:
plz it take lots of time and energy so plz mark me brainliest