Question

In: Computer Science

<!DOCTYPE html> <html> <body> <script> // // The colors red, blue, and yellow are known as...

<!DOCTYPE html>
<html>
<body>
<script>
//
// The colors red, blue, and yellow are known as the primary colors because they
// cannot be made by mixing other colors. When you mix two primary colors, you
// get a secondary color, as shown here:
//
//              When you mix red and blue, you get purple.
//              When you mix red and yellow, you get orange.
//              When you mix blue and yellow, you get green.
//
// Design a program that prompts the user to enter the names of two primary colors
// to mix. If the user enters anything other than “red,” “blue,” or “yellow,” the
// program should display an error message. Otherwise, the program should display
// the name of the secondary color that results.
//

function findSecondaryColor(color1, color2) {

/////////////////////////////////////////////////////////////////////////////////
// Insert your code between here and the next comment block.  Do not alter     //
// any code in any other part of this file.                                    //
/////////////////////////////////////////////////////////////////////////////////


/////////////////////////////////////////////////////////////////////////////////
// Insert your code between here and the previous comment block.  Do not alter //
// any code in any other part of this file.                                    //
/////////////////////////////////////////////////////////////////////////////////

}

var color1 = prompt("What is the first primary color you'd like to mix? (red, blue or yellow) ");
var color2 = prompt("What is the first second color you'd like to mix? (red, blue or yellow) ");

alert(findSecondaryColor(color1, color2));

</script>
</body>
</html>

Solutions

Expert Solution

<!DOCTYPE html>
<html>
<body>
<script>
//
// The colors red, blue, and yellow are known as the primary colors because they
// cannot be made by mixing other colors. When you mix two primary colors, you
// get a secondary color, as shown here:
//
// When you mix red and blue, you get purple.
// When you mix red and yellow, you get orange.
// When you mix blue and yellow, you get green.
//
// Design a program that prompts the user to enter the names of two primary colors
// to mix. If the user enters anything other than “red,” “blue,” or “yellow,” the
// program should display an error message. Otherwise, the program should display
// the name of the secondary color that results.
//

function findSecondaryColor(color1, color2) {

/////////////////////////////////////////////////////////////////////////////////
// Insert your code between here and the next comment block. Do not alter //
// any code in any other part of this file. //
/////////////////////////////////////////////////////////////////////////////////

if((color1=="red" && color2=="blue")|| (color1=="blue" && color2=="red"))
return "purple";
else if((color1=="red" && color2=="yellow")||(color1=="yellow" && color2=="red"))
return "orange"
else if((color1=="blue" && color2=="yellow")||(color1=="yellow" && color2=="blue"))
return "green"
else
return "Invalid Input";


/////////////////////////////////////////////////////////////////////////////////
// Insert your code between here and the previous comment block. Do not alter //
// any code in any other part of this file. //
/////////////////////////////////////////////////////////////////////////////////

}

var color1 = prompt("What is the first primary color you'd like to mix? (red, blue or yellow) ");
var color2 = prompt("What is the first second color you'd like to mix? (red, blue or yellow) ");

alert(findSecondaryColor(color1, color2));

</script>
</body>
</html>

/* PLEASE UPVOTE */


Related Solutions

PYTHON PROGRAMMING The colors red, blue, and yellow are known as the primary colors because they...
PYTHON PROGRAMMING The colors red, blue, and yellow are known as the primary colors because they cannot be made by mixing other colors. When you mix two primary colors, you get a secondary color, as shown here: Red and blue = purple Red and yellow = orange Blue and yellow = green For this program, you will employ list data structures to store a group of objects by designing a program that prompts the user to enter the names of...
<!DOCTYPE html> <html> <body> <script> // // A car's miles-per-gallon (MPG) can be calculated with the...
<!DOCTYPE html> <html> <body> <script> // // A car's miles-per-gallon (MPG) can be calculated with the following formula: // // MPG=Milesdriven/Gallonsofgasused // // Write a program that asks the user for the number of miles driven and the // gallons of gas used. It should then call a function to calculate and return // the car's MPG and display the result. // function calculateMPG(miles, gas) { ///////////////////////////////////////////////////////////////////////////////// // Insert your code between here and the next comment block. Do not...
Twelve chairs are to be painted. The available colors are Red, Blue, Green, and Yellow, and...
Twelve chairs are to be painted. The available colors are Red, Blue, Green, and Yellow, and every chair must be painted with one color. Assuming that all coloring schemes are equally likely, what is the probability that one color is not used and there are at least two chairs of every other color ? (The answer is 0.25) Can anyone explain to me why ?
<!DOCTYPE html> <html> <body> <!-- replace the text below with your name!--> <!-- --> <!-- -->...
<!DOCTYPE html> <html> <body> <!-- replace the text below with your name!--> <!-- --> <!-- --> <title> TYPE YOUR NAME HERE</title> <script> // // A bug collector collects bugs every day for five days. Write a function that keeps // a running total of the number of bugs collected during the five days. The loop // should ask for the number of bugs collected for each day, and when the loop is // finished, the program should display the total...
<!DOCTYPE html> <html> <body> <!-- replace the text below with your name!-->    <!-- -->   ...
<!DOCTYPE html> <html> <body> <!-- replace the text below with your name!-->    <!-- -->    <!-- -->    <title> name </title> <script> // // Write a function that calculates the amount of money a person would earn over // a period of years if his or her salary is one penny the first day, two pennies // the second day, and continues to double each day. The program should ask the // user for the number of years and...
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",...
Chocolates N&N come in 3 colors: blue, red and yellow. A chocolate bag should, on average,...
Chocolates N&N come in 3 colors: blue, red and yellow. A chocolate bag should, on average, be filled with 40% of blue, 40% of red and 20% of yellow. The supervisor test the machine by taking a sample of bags. He counts 85 blue, 106 red, and 43 yellow in this sample. α = 0.05 a) What are the null and alternative hypothesis? Define any necessary variables. b) What is the test statistic? c) What is the critical value or...
Can someone verify why my code isnt running <!DOCTYPE html> <html> <body bgcolor=aqua text=purple> <script type="text/javascript">...
Can someone verify why my code isnt running <!DOCTYPE html> <html> <body bgcolor=aqua text=purple> <script type="text/javascript"> funtion oldMacVerse(animal, sound) //Assumes: animal is the name of an animal, sound is the sound it makes //Results: displays a version of the song "Old MacDonals Had a Farm" in outputDiv { document.getElementById('outputDiv').innerHTML =    '<p>Old MacDonald had a farm, E-I-E-I-O.<br>' +    'And on that farm he had a ' + animal + ', E-I-E-I-O.<br>' +    'With a ' + sound +...
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