In: Computer Science
The following shows the French translation for some colours: English French red rouge orange orange yellow jaune green vert blue bleu Create a program ColourTranslator that displays the French translation of the English colour obtained from the user. E.g.: System: Enter a colour in English: User: red System: The French word for red is rouge. Include a default case that handles input that is not on the list. e.g. System: Enter a colour in English User: purple System: Sorry, purple is not in the list.
Java code
============================================================================================
import java.util.Scanner;
public class FrenchTranslation {
public static void main(String[] args) {
// TODO Auto-generated method
stub
String s;
//scanner class object for taking
input from keyboard
Scanner sc = new
Scanner(System.in);
System.out.print("Enter a colour in
English:");
s=sc.next();
switch(s)
{
case "red":
System.out.println("The French word for red is rouge.");
break;
case "orange":
System.out.println("The French word for orange is orange.");
break;
case "yellow":
System.out.println("The French word for yellow is jaune.");
break;
case "green":
System.out.println("The French word for green is vert.");
break;
case "blue":
System.out.println("The French word for blue is bleu.");
break;
default:
System.out.println("Sorry, "+s+" is not in the list.");
break;
}
}
}
============================================================================================
Output