subject

There are several syntax errors in the code that are preventing this calculator from working, find and fix those errors. When they are fixed, the number buttons will all work, as well as the + (add) and -- (decrement) buttons. To find the errors, open up the Developers Tool of the browser (F12) and look at the console.
Find the line number of the file and click on it to see the source code and find the error
There are 4 errors in the JavaScript file and 1 error in HTML file
Verify the "add" functionality works. For a binary operator, you must click on the buttons in the following order:
Hit a number button
Hit the ‘+’ button
Hit a number button
Hit the ‘Calculate’ button
Verify the decrement operator works. For a unary operator, you must click the buttons in the following order:
Hit the number button
Hit the ‘—‘ button
Implement subtraction in a similar fashion to addition:
Create a subtract function. To subtract, the user must hit a number button, then the ‘-‘ button, another number button and then the ‘Calculate’ button. The function should store the first number in a global variable, similar to the add function.
Add code in the calculate button which will perform the subtraction when the ‘Calculate’ button is clicked.
Call the subtract function from the HTML file.
Implement the sqrt() button. Similar to the decrement function, the sqrt() button will take the value of the number and display the square root. Use the Math. sqrt function to calculate the square root.
Code :
//Global variables

var prevCalc = 0;
var calc = "";
//The following function displays a number in the textfield when a number is clicked.
//Note that it keeps concatenating numbers which are clicked.
function showNum(value) {
document. frmCalc. txtNumber. value += = value;
}
//The following function decreases the value of displayed number by 1.
//isNaN method checks whether the value passed to the method is a number or not.
function decrement() {
var num = parseFloat(document. frmCalc. txtNumber. value);
if (!(isNaN(num))) {
num--;
document. frmCalc. txtnumber. value = num;
}
}
//The following function is called when "Add" button is clicked.
//Note that it also changes the values of the global variables.
function add() {
var num = parseFloat(document. frmCalc. txtNumber. value);
if (!(isNaN(num))) {
prevCalc = num;
document. frmCalc. txtNumber. value = "";
calc = "Add";
}
}
//The following function is called when "Calculate" button is clicked.
//Note that this function is dependent on the value of global variable.
function calculate() {
var num = parseFloat(document. frmCalc. txtNumber. value);
if (!(isNaN(num))) {
if (calc == "Add"){
var total = previousCalc + num;
document. frmCalc. txtNumber. value = total;
}
}
function clear() {
document. frmCalc. txtNumber. value = "";
prevCalc = 0;
calc = "";
}

ansver
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 09:40, cutybrain6054
Sarah is having a hard time finding a template for her advertising business that she may be able to use at a later date and also make it available to her colleagues
Answers: 1
image
Computers and Technology, 23.06.2019 09:30, rowdycar313p0ao5k
[java] create an application called registrar that has the following classes: a. a student class that minimally stores the following data fields for a student: - name - student id number - number of credits - total grade points earned and this class should also be provides the following methods: - a constructor that initializes the name and id fields - a method that returns the student name field - a method that returns the student id field - methods to set and retrieve the total number of credits - methods to set and retrieve the total number of grade points earned. - a method that returns the gpa (grade points divided by credits) b. an instructor class that minimally stores the following data fields for an instructor: - name - faculty id number - department the following methods should be provided: - a constructor that initializes the name and id fields - methods to set and retrieve the instructor’s department. c. a course class that minimally stores the following data for a course: - name of the course- course registration code- maximum number of 35 students- instructor- number of students- students registered in the course (an array)the following methods should also be provided: - a constructor that initializes the name, registration code, and maximum number of students- methods to set and retrieve the instructor- a method to search for a student in the course; the search should be based on an id number.- a method to add a student to the course. if the course is hill, then an exception with an appropriate message should be raised (try creating your own exception class for this). also, be sure that the student is not already registered in the course. the list of students should be in the order that they registered.- a method to remove a student from the course. if the student is not found, then an exception with an appropriate message should be raised (use the same exception class mentioned a method that will allow course objects to be output to a file using object serialization- a method that will allow course objects to be read in from a file created with object serializationyou will note that the student and instructor classes described above have some commonality. create aperson class that captures this commonality and uses it as a base class for student and instructor. this class should be responsible for the name and id fields and also provide atostring method that returns a string of the form name, id. this will be the inheritedtostring method for the student and instructor classes.1. draw a uml diagram for diss application.2. implement the previous classes in java. write a main program that can serve as a test class that tests all of the methods created and demonstrates that they are working
Answers: 2
image
Computers and Technology, 23.06.2019 17:30, Annlee23
When making changes to optimize part of a processor, it is often the case that speeding up one type of instruction comes at the cost of slowing down something else. for example, if we put in a complicated fast floating-point unit, that takes space, and something might have to be moved farther away from the middle to accommodate it, adding an extra cycle in delay to reach that unit. the basic amdahl's law equation does not take into account this trade-off. a. if the new fast floating-point unit speeds up floating-point operations by, on average, 2ă—, and floating-point operations take 20% of the original program's execution time, what is the overall speedup (ignoring the penalty to any other instructions)? b. now assume that speeding up the floating-point unit slowed down data cache accesses, resulting in a 1.5ă— slowdown (or 2/3 speedup). data cache accesses consume 10% of the execution time. what is the overall speedup now? c. after implementing the new floating-point operations, what percentage of execution time is spent on floating-point operations? what percentage is spent on data cache accesses?
Answers: 2
image
Computers and Technology, 23.06.2019 19:50, Aprillove7939
Which feature is selected to practice and save the timing of a presentation
Answers: 1
You know the right answer?
There are several syntax errors in the code that are preventing this calculator from working, find a...

Questions in other subjects:

Konu
Mathematics, 08.12.2020 19:50
Konu
History, 08.12.2020 19:50
Konu
Spanish, 08.12.2020 19:50