Create a web page that displays the default information (example shown). (1 poin
ID: 3818197 • Letter: C
Question
Create a web page that displays the default information (example shown). (1 point each, total 3 points)
The initial page and related outputs should look like the examples shown below. (4 points output format)
Create your page using “<your name>’s Richard Ricardo's Kung Fu Panda Po Magic Functions” as the page title. Save the page as index.htm. Remember to document the html file with html comments. (1 point each, total 3 points)
Allow the user to enter two magic numbers.
Make sure the numbers are positive (3 points)
The JavaScript code should include four functions as described below (4 points each, total 16 points)
The main function RichardMath() describe the selections, prompts user for two numbers (save as variables x and y), and call the other three functions
Function RichardExp(x,y) calculate the value xy, and return the result
Function RichardArea(x,y) calculate the area of a rectangle (area = base * height), and return the result
Initial Page:
Input 1
OUTPUT IF POSITIVE INT IS NOT ENTERED
CORRECTED INPUT
WEBPAGE OUTPUT:
d =-f(x2+(y2-y1Explanation / Answer
<!-- Use Chrome or Mozilla browser for best result -->
<html>
<head>
<title>
Richard Ricardo's Kung Fu Panda Po Magic Functions
</title>
<style>
#title {
height: 20%;
border: 1px solid;
background-color:rgba(30, 93, 52, 0.58);
}
#h1Title {
color:green;
text-align:center;
margin-top: 30px;
font-size: 45px;
}
#content{
background-color:lightgray;
height: 80%;
margin-top: -25px;
}
h1,h2,span,p {
color:green;
text-align:center
}
#result {
border:1px solid;
height: 250px;
margin-top: 20px;
color:green;
font-size: 25px;
}
</style>
<script>
function richardMath() {
var x = parseInt(prompt("Enter a positive number", "0"));
if(x < 0) {
var x = parseInt(prompt("The number must be Poitive. Please re-enter:", "0"));
}
var y = parseInt(prompt("Enter a positive number", "0"));
if(y < 0) {
var y = parseInt(prompt("The number must be Poitive. Please re-enter:", "0"));
}
var result = "Richard's First Number = " + x +"<br/>";
result += "Richard's Second Number = " + y +"<br/>";
result += richardExp(x,y) + "<br/>";
result += richardArea(x,y) + "<br/>";
result += richardDistance(x,y) + "<br/>";
document.getElementById("result").innerHTML= result;
}
function richardExp(x,y){
return ""+x+"<sup>"+y+"</sup> = " + Math.pow(x,y);
}
function richardArea(x,y) {
return "The area of a rectangle with base of "+ x +" and a height of "+ y +"= "+x + "*" + y + " = " + x*y;
}
function richardDistance(x,y) {
return "The distance between two points (0,0) and ("+x+","+y+") = √((" +x+"-0)<sup>2</sup> + (" +y+"-0)<sup>2</sup>) = " + Math.sqrt((Math.pow(x-0,2))+(Math.pow(y-0,2)));
}
</script>
</head>
<body>
<div id="title"><h1 id="h1Title"">Richard Ricardo's Kung Fu Panda Po Magic Functions<h1></div>
<div id="content">
<h1><span>C</span>lick on the button to enter Po's two magic numbers.</h1>
<br>
<h2>Richard will take the numbers and do the calculation for you using his magical functions. </h2>
<input type="button" value="Enter two magic numbers begin"/>
<div id="result"></div>
</div>
</body>
</html>
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.