clio 182 black /gold
(i) A JavaScript program is intended to accept two numbers from a user,
then write the sum and difference of the two numbers to the browser
window. For example, if the user inputs 36 and 24 the program should
write
The sum of 36 and 24 is 60
The difference of 36 and 24 is 12
However, the current version (Figure 6) contains several errors. Your
task is to identify them, correct the program, and write a short
explanation of each of your changes.
<SCRIPT LANGUAGE="JavaScript">
// A program to find the sum and difference of two numbers
var firstNum;
varsecondNum;
firstNum = window.prompt('Please enter the first number., '');
firstNum = ParseFloat(firstNum);
secondNum = window.prompt('Please enter the second number', '');
secondNum = parseFloat(secondNum);
document.write'The sum of ' + first + ' and ' + secondNum + ' is
' + (firstNum + secondNum) + '<BR>');
document.write('The difference of ' firstNum + ' and ' +
secondNum + ' is ' + (firstNum+ secondNum) + <BR>);
</SCRIPT>
then write the sum and difference of the two numbers to the browser
window. For example, if the user inputs 36 and 24 the program should
write
The sum of 36 and 24 is 60
The difference of 36 and 24 is 12
However, the current version (Figure 6) contains several errors. Your
task is to identify them, correct the program, and write a short
explanation of each of your changes.
<SCRIPT LANGUAGE="JavaScript">
// A program to find the sum and difference of two numbers
var firstNum;
varsecondNum;
firstNum = window.prompt('Please enter the first number., '');
firstNum = ParseFloat(firstNum);
secondNum = window.prompt('Please enter the second number', '');
secondNum = parseFloat(secondNum);
document.write'The sum of ' + first + ' and ' + secondNum + ' is
' + (firstNum + secondNum) + '<BR>');
document.write('The difference of ' firstNum + ' and ' +
secondNum + ' is ' + (firstNum+ secondNum) + <BR>);
</SCRIPT>