Computer Science, asked by ashishdevgan, 2 months ago

4. Rewrite the following if statement, using the switch statement:
if (choice 0)
System.out.println("You selected Blue");
else if (choice == 1)
System.out.println("You selected Cyan");
else if (choice == 2)
System.out.println("You selected Red");
else if (choice :3)
System.out.println("You selected Magenta");
else if (choice
4)
System.out.println("You selected Green");
else if (choice 5)
System.out.println("You selected Yellow");
else
System.out.println("Invalid choice");​

Answers

Answered by saanavishelar02
3

Answer:

Scanner sc= new scanner(System.in);

S.O.P ("1.Blue");

S.O.P("2 Cyan");

S.O.P("3.Red");

S.O.P("4.Magenta");

System.out.println ("5.Green");

S.o.p ("6.Yellow");

s.o.p("7.Enter your choise");

switch (ch)

{

case 1:

s.o.p("Enter your choice");

b=sc.nextDouble();

}

break;

case2:

continue

Similar questions