subject

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.

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 15:00
Hyperactive media sales has 10 windows 7 laptop computers used by sales-people in the organization. each laptop computer has several customized applications that are used during the sales process as well as customer relationship management software. all of the applications on the laptops are difficult to configure and have large data files. if all of the laptops have current hardware, what is the easiest way to install windows 10 on them?
Answers: 1
question
Computers and Technology, 22.06.2019 19:20
Write a program that reads a file consisting of students’ test scores in the range 0–200. it should then determine the number of students having scores in each of the following ranges: 0–24, 25–49, 50–74, 75–99, 100–124, 125–149, 150–174, and 175–200. output the score ranges and the number of students. (run your program with the following input data: 76, 89, 150, 135, 200, 76, 12, 100, 150, 28, 178, 189, 167, 200, 175, 150, 87, 99, 129, 149, 176, 200, 87, 35, 157, 189.)
Answers: 3
question
Computers and Technology, 23.06.2019 06:00
When is a chart legend used a. all the time b. whenever you are comparing data that is the same c. whenever you are comparing multiple sets of data d. only for hand-drawn charts
Answers: 2
question
Computers and Technology, 23.06.2019 07:30
Write a program that inserts the digits of an integer into an array in originalorderfollowed by reverse order. first, promptthe user to enter a positive integer(> 0). determine the number of digits of the integer. create a dynamically allocated integer arrayof a size twice the number of digits.now insert the digits in original order which will occupy half of the array. then, insert the digits in reverse order.finally, output thedigits in thearray.use at least two functions to organize your program.
Answers: 3
You know the right answer?
For this activity, you will practice being both proactive and reactive to bugs. Both are necessary t...
Questions
question
Mathematics, 21.05.2021 18:40
question
Biology, 21.05.2021 18:40
question
Mathematics, 21.05.2021 18:40
Questions on the website: 13722360