Question

In: Computer Science

The following shows the French translation for some colours: English French red rouge orange orange yellow...

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.

Solutions

Expert Solution

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


Related Solutions

The colours red, blue, and yellow are known as the primary colours because they cannot be...
The colours red, blue, and yellow are known as the primary colours because they cannot be made by mixing other colours. When you mix two primary colours, you get one of following secondary colour: -Mix red and blue: purple -Mix red and yellow: orange -Mix blue and yellow: green Write a function colour_mix that takes two strings as parameters as two primary colours and returns the secondary colour. If the parameters are anything other than "red", "blue", or "yellow", the...
The colours red, blue, and yellow are known as the primary colours because they cannot be...
The colours red, blue, and yellow are known as the primary colours because they cannot be made by mixing other colours. When you mix two primary colours, you get one of following secondary colour: - Mix red and blue: purple - Mix red and yellow: orange - Mix blue and yellow: green Write a function colour_mix that takes two strings as parameters as two primary colours and returns the secondary colour. If the parameters are anything other than "red", "blue",...
You have 50 of each of the following kinds of jellybeans: red, orange, green, yellow. The...
You have 50 of each of the following kinds of jellybeans: red, orange, green, yellow. The jellybeans of each color are identical. (a)how many ways can you put all the jellybeans in a row? (b)How many handfuls of 12 are possible?
Methyl orange changes from red at pH 3.1 to yellow at pH 4.4. Would methyl orange...
Methyl orange changes from red at pH 3.1 to yellow at pH 4.4. Would methyl orange be a suitable indicator for the titration of propanoic acid (pKa=4.87, Ka=1.34x10^-5) with 0.01 M NaOH? Explain. Phenolphthalein changes from colorless at pH 8.0 to pink at pH 9.6. Would phenolphthalein be a suitable indicator for the titration of propanoic acid with 0.01 M NaOH? Explain.
Brian is selling balloons in 8 different colours: red, pink, yellow, blue, green, purple, black and...
Brian is selling balloons in 8 different colours: red, pink, yellow, blue, green, purple, black and silver. How many different selections of 16 helium balloons can be purchased if the shop has at least 16 balloons of each colour in stock? How many different selections of 16 helium balloons can be purchased if you buy at least 3 red balloons and at least 5 yellow balloons, and the shop has at least 16 balloons of each colour in stock? How...
Consider the following dataset: x1 Yellow Yellow Green Green Red Red Green Red Yellow x2 5...
Consider the following dataset: x1 Yellow Yellow Green Green Red Red Green Red Yellow x2 5 2 10 4 3 7 2 5 4 y 1 3 7 5 10 18 4 8 3 (a) (3pts) Split the data into a train and test set where the test set contains observations 1 and 7. Answer this by writing down the two datasets. (b) (2pts) Use Rstudio to estimate a model (which uses both x1 and x2 as predictor variables) using...
A shop sells helium balloons in eight different colours: red, pink, yellow, blue, green, purple, black...
A shop sells helium balloons in eight different colours: red, pink, yellow, blue, green, purple, black and silver. (a) How many different selections of 16 helium balloons can be purchased if the shop has at least 16 balloons of each colour in stock? (b) How many different selections of 16 helium balloons can be purchased if you buy at least 3 red balloons and at least 5 yellow balloons, and the shop has at least 16 balloons of each colour...
(5 pts) Suppose that the five standard Skittles colors (red, orange, yellow, green, purple) occur with...
(5 pts) Suppose that the five standard Skittles colors (red, orange, yellow, green, purple) occur with equal relative frequency. Use the random digits below to simulate the colors of 4 randomly selected Skittles. Continue to do this until you have generated 12 such samples of 4 Skittles. Use the results of these simulations to approximate that probability that a sample of 4 Skittles will contain at least two Skittles of the same color. 28491 06339 65216 31007 92314 50271 82943...
Red Orange Yellow Green Purple Total 1046.    1066 977 1029 969 5087 Suppose all of...
Red Orange Yellow Green Purple Total 1046.    1066 977 1029 969 5087 Suppose all of the Skittles in the class data set are combined into one large bowl and you are going to randomly select ten Skittles with replacement and count how many are yellow. (a) List the requirements of the binomial probability distribution and show that this meets them, including identifying the values for n and p. (6 points) (b) What is the probability that exactly 4 of...
The distribution of M&M colors is 24% blue, 20% orange, 16% green, 14% yellow, 13% red,...
The distribution of M&M colors is 24% blue, 20% orange, 16% green, 14% yellow, 13% red, and 13% brown. You have a small bag of M&M's and count the colors. Your bag has 9 blue, 9 orange, 4 green, 12 yellow, 3 red, and 6 brown M&M's. Before you begin, how many M&M's do you need in your sample (minimum) to be able to do this test? Remember, your assumption for chi-square is that every expected frequency has at least...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT