際際滷

際際滷Share a Scribd company logo
Testing and debugging a
program
When we write a program and it does not
produce an output, this is known as a
bug.To find these bugs and resolve any
errors is known as Debugging.
Find the one error in this code?
<html>
<body>
<script type="text/javascript">
var name = p ("enter your name","");
document.write(name.substring(0,1));
</script>
</body>
</html>
Find the two errors in this code?
<html>
<body>
<script type="javascript">
var maxmarks = prompt("enter the max marks of test","");
var marks = prompt("enter the marks of test","");
maxmarks=parseInt(maxmarks);
marks=parseInt(marks);
var percen=marks/maxmarks*100
if(percen>80)
{
document.write("you have",percen,"% in this test");
document.write("<PRE>nCongratulations for your performance </PRE>");
}
And
{
document.write (" you need to work a little more for excellence");
document.write ("<PRE>nPlan better and you will be there</PRE>");
}
</script>
</body>
</html>
Find five errors in this code?
<html>
<body>
<script type="text/javascript">
var marks = prompt("enter the marks of test","")
marks=parseInt(m);
if(marks60)
{
document.write("grade is a")
else if (marks >=45)
{
document.write("grade is b")
}
else if (marks >=30)
{
document.write("grade is c")
}
else
{
document.write("grade is f")
}
</body>
</html>
Programming activity

Write a program that will display a
message, the message can be anything
you want.
*Use the keyword document.write.

Write a program that will display either a
yes or no message when you enter a
number. For example to see if a number
divides by 2 or 3.
*Remember to use the if condition and the
keyword parseInt for this program.

Write a program that will display either a
yes or no message when you enter a
number. For example to see if a number
divides by 2 or 3.
*Remember to use the if condition and the
keyword parseInt for this program.

More Related Content

Activity lesson

  • 1. Testing and debugging a program When we write a program and it does not produce an output, this is known as a bug.To find these bugs and resolve any errors is known as Debugging.
  • 2. Find the one error in this code? <html> <body> <script type="text/javascript"> var name = p ("enter your name",""); document.write(name.substring(0,1)); </script> </body> </html>
  • 3. Find the two errors in this code? <html> <body> <script type="javascript"> var maxmarks = prompt("enter the max marks of test",""); var marks = prompt("enter the marks of test",""); maxmarks=parseInt(maxmarks); marks=parseInt(marks); var percen=marks/maxmarks*100 if(percen>80) { document.write("you have",percen,"% in this test"); document.write("<PRE>nCongratulations for your performance </PRE>"); } And { document.write (" you need to work a little more for excellence"); document.write ("<PRE>nPlan better and you will be there</PRE>"); } </script> </body> </html>
  • 4. Find five errors in this code? <html> <body> <script type="text/javascript"> var marks = prompt("enter the marks of test","") marks=parseInt(m); if(marks60) { document.write("grade is a") else if (marks >=45) { document.write("grade is b") } else if (marks >=30) { document.write("grade is c") } else { document.write("grade is f") } </body> </html>
  • 5. Programming activity Write a program that will display a message, the message can be anything you want. *Use the keyword document.write.
  • 6. Write a program that will display either a yes or no message when you enter a number. For example to see if a number divides by 2 or 3. *Remember to use the if condition and the keyword parseInt for this program.
  • 7. Write a program that will display either a yes or no message when you enter a number. For example to see if a number divides by 2 or 3. *Remember to use the if condition and the keyword parseInt for this program.