write a Java program to accept rainbow colours using switch statement in scanner class. method required !!
Answers
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:
it take lots of time and energy so plz mark me brainliest