CodeHub Menu
Home Exercise Practice About Download Portfolio Play Games NEW Privacy Policy Terms Contact
Login / Register

seven colour sproctrom VIBGYOR in JAVA

JAVA November 27, 2025 10 views 0 likes
Write a program a java to input a choice of character amd print the seven colour sproctrom VIBGYOR

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(); } }

Output

VIBGYOR Color Checker

VIBGYOR Color Spectrum

10 views 0 likes
Total visits: 2,089 • Unique visitors: 1,285