Computers and Technology
Computers and Technology, 07.06.2021 23:00, yuu59

For this activity, you will practice being both proactive and reactive to bugs. Both are necessary to get rid of errors in code. Proactive:

Log in to REPL. it and open your Calculator program that you built in Unit 5.
In the index. js file, type and finish the following block of code that validates the input to make sure both are numbers (not letters or symbols):
try{
if (isNaN(…) || isNaN(…)){
throw …
}
else{
document. getElementById("answer").innerHTML = num1 + num2;
}
}
catch(e){
document. getElementById("answer")…
}

(Note: The || symbol is used in JavaScript to mean or . You can find this key to the left of the Z key if you’re using a PC or directly above the Enter key if you’re using a Mac.)
Add the finished code above to the correct place in your add() function. Make sure to delete this line since we moved it into the try block:
document. getElementById("answer").innerHTML = num1 + num2;
Paste the same code into the subtract() , multiply() , and divide() functions, making the necessary changes. Be careful with your divide() function since you already have an extra if else statement checking for a division by 0 mistake. (Hint: Cut and paste the entire if else statement inside the else block of your try statement.)
Test your program by typing in letters or symbols instead of numbers. Make sure you get the appropriate error message. (Note: The function is not supposed to check whether the text field is empty, only whether it contains non-numbers.)
When you are finished, share the link to your webpage with your teacher by clicking on the share button and copying the link.
Reactive:
The following Python program should print the sum of all the even numbers from 0 to 10 (inclusive), but it has two bugs:

x = 0
sum = 0
while x < 10:
sum = sum + x
x = x + 1
print(sum)
Complete a trace table and then write a sentence or two explaining what the errors are and how to fix them. You can choose whether to do the trace table by hand or on the computer. Turn in your trace table and explanation to your teacher.

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 11:00, paigesyring
How does a policy manual an organization? a. it boost productivity. b. it create awareness in employees about the organization’s values. c. it employees achieve targets. d. it safeguards the organization from liabilities.
Answers: 1
image
Computers and Technology, 22.06.2019 21:00, raquelle66
So im doing this school challenge and the teachers said whats the average text a student gets a day so i need to get about 20 in a day but dont know how can you guys 2163371293
Answers: 2
image
Computers and Technology, 23.06.2019 09:00, jeremytheprimerapper
Which best compares appointments and events in outlook 2010appointments have a subject man, and events do notappointments have a specific date or range of dates, and events do notappointments have a start and end time of day, and events do notappointments have a location option, and events do not
Answers: 2
image
Computers and Technology, 23.06.2019 09:30, shadowsnake
Write a function called checkfactor that takes two arrays of positive numbers, firstnumberrow and secondnumberrow. checkfactor checks if the first entry in firstnumberrow is divisible by the first entry in secondnumberrow, and performs the same operation on the next array elements until all entries have been checked. all the numbers are positive and the number of entries in the arrays are the same. the function should return the identified divisible numbers in two row arrays named firstdivisible and seconddivisible. restrictions: branches or loops should not be used. the code must use the internal mod and logical functions. hint: the mod function should be used to determine if two numbers are divisible. ex: for num1 and num2 if mod(num1,num2) is 0, then the two numbers are divisible. this is matlab
Answers: 2
Do you know the correct answer?
For this activity, you will practice being both proactive and reactive to bugs. Both are necessary t...

Questions in other subjects: