Hi everybody, ?
I am trying to convert some of my programs into pseudocode but I really do not know what I’m doing. ? Some help would be very much appreciated. ?
This is my first program and my outcome of pseudocode for it:
[code]
<html>
<head>
<title>Largest or Equals</title>
<script type = “Text/JavaScript”>
<!– Hides the JavaScript from browsers
var number1 = parseInt(prompt(“Please enter your first number…”,””));
var number2 = parseInt(prompt(“Please enter your second number…”,””));
if (number1 > number2)
{
alert(number1 + ” is the largest number!”);
}
else
if (number2 > number1)
{
alert(number2 + ” is the largest number!”);
}
else
{
alert(“Both of the numbers are equal!”);
}
// Ends the hiding comment –>
</script>
</head>
<body>
</body>
</html>
Pseudocode for it:
[code]
read in first number
read in second number
if first number > second number then
write out first number is the largest
else
if second number > first number then
write out second number is the largest
else
write out first number and second number are equal
This is my second program, but now I’m totally confused about what to do for functions and loops, as well as their conditions, etc:
[code]
<html>
<head>
<title>Powers from Function</title>
<script type = “Text/JavaScript”>
<!– Hides the JavaScript from browsers
function powers()
{
var number = parseInt(prompt(“Please enter a number to view its powers…”,””));
for (i = 0; i <= 10; i ++)
{
document.write(number + ” to the power of ” + i + ” = ” + Math.pow(number,i));
document.write(“<br />”);
}
}
// Ends the hiding comment –>
</script>
</head>
<body>
<input type=”button” onclick=”powers()” value=”Powers Calculator”/>
</body>
</html>