Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

HTML Assignment question. Ex5-3 Write a script that asks the user to enter 3 num

ID: 3727202 • Letter: H

Question

HTML Assignment question.

Ex5-3 Write a script that asks the user to enter 3 numbers then you will output three rows of stars that corresponding to the numbers entered. Note the numbers entered by the user cannot greater than 20 or less than 5. The second screen shot I not acceptable since user entered 234 which is greater than 20 This page says: This page says This page The program will output three lines of stars. With the first one 10 stars in red, second line 15 stars in yellow and the third line 12 stars in blue

Explanation / Answer

<!DOCTYPE HTML>
<html lang="en-us">
<head>
<meta charset="utf-8">
<title>Title</title>
<script type="text/javascript">
function myFunction() {

var first =prompt("Please enter first number",10);

var a=parseInt(first);
if(b>20 || b<5)
{
alert("Please enter a valid number");
first =prompt("Please enter first number",10);
a=parseInt(first);
}
var res="";
for(var i=0;i<a;i++)
{
res=res+"*";
}

document.getElementById("output1").innerHTML =res;
var second =prompt("Please enter second number",15);
var b=parseInt(second);
if(b>20 || b<5)
{
alert("Please enter a valid number");
second =prompt("Please enter second number",15);
b=parseInt(second);
}
var res1="";
for(var i=0;i<b;i++)
{
res1=res1+"*";
}

document.getElementById("output2").innerHTML =res1;

var third =prompt("Please enter third number",15);
var c=parseInt(third);
var res2="";
   if(c>20 || c<5)
{
alert("Please enter a valid number");
third =prompt("Please enter third number",10);
c=parseInt(third);
}
else
{
for(var i=0;i<c;i++)
{
res2=res2+"*";
}
}

document.getElementById("output3").innerHTML =res2;
}

</script>

</head>

<body>
<div id="output1"></div>
<div id="output2"></div>
<div id="output3"></div>
</body>
</html>
   

output