Home Answers Viewqa JavaScriptQuestions cannot do the additional operator

 
 


siti umairah
cannot do the additional operator
2 Answer(s)      7 months ago
Posted in : JavaScript Questions

i got problem with additional and multiplication operator...please anyone help me

<html>
<head>
<title>Simple Calculator</title>
<script language = "JavaScript">
// calculate function
function calculate () {
//get input from first text field
var numberFirst = formCalculator.num1.value;
//get input from first text field
var operator = formCalculator.operator.value;
//get input from first text field
var numberSecond = formCalculator.num2.value;
var total; // variable declaration
var output; // variable declaration
// if else..if
if (operator == "+" )
total = numberFirst + numberSecond;
else if (operator == "-")
total = numberFirst - numberSecond;
else if (operator == " * ")
total = numberFirst * numberSecond;
else
total = numberFirst / numberSecond;
// output from pop up alert window
output = alert ( numberFirst + " " + operator + " " + numberSecond + " = " + total);
}
</script>
</head>
<body>
<p align="center" class="style1">Simple Calculator</p>
<!-- HTML form-->
<form name = "formCalculator">
<p align="center">
<!-- first text field -->
<input type="text" name="num1">
<!-- selection math operator menu -->
<select name="operator">
<option selected value="+" > +
<option value= "-" > -
<option value= "*" > *
<option value= "/" > /
</select>
<!-- second text field -->
<input type="text" name="num2">
</p>
<p align="center">
<input type="reset" name="Reset" value="Cancel">
<!-- submit button call calculate function -->
<input type="submit" name="Submit" value="Calculate" onClick= "calculate()">
</p>
</form>
</body>
</html>
View Answers

October 4, 2012 at 6:07 PM


We have modified your simple calculator program.

<html>
<head>
<title>Simple Calculator</title>
<script language = "JavaScript">
// calculate function
function calculate () {
//get input from first text field
var numberFirst = formCalculator.num1.value;
//get input from first text field
var operator = formCalculator.operator.value;
//get input from first text field
var numberSecond = formCalculator.num2.value;
var total; // variable declaration
var output; // variable declaration
// if else..if
if (operator == "+" )
total = parseInt(numberFirst) + parseInt(numberSecond);
else if (operator == "-")
total = parseInt(numberFirst) - parseInt(numberSecond);
else if (operator == " * ")
total = parseInt(numberFirst) * parseInt(numberSecond);
else
total = parseInt(numberFirst) / parseInt(numberSecond);
// output from pop up alert window
output = alert ( numberFirst + " " + operator + " " + numberSecond + " = " + total);
}
</script>
</head>
<body>
<p align="center" class="style1">Simple Calculator</p>
<!-- HTML form-->
<form name = "formCalculator">
<p align="center">
<!-- first text field -->
<input type="text" name="num1">
<!-- selection math operator menu -->
<select name="operator">
<option selected value="+" > +
<option value= "-" > -
<option value= "*" > *
<option value= "/" > /
</select>
<!-- second text field -->
<input type="text" name="num2">
</p>
<p align="center">
<input type="reset" name="Reset" value="Cancel">
<!-- submit button call calculate function -->
<input type="submit" name="Submit" value="Calculate" onClick= "calculate()">
</p>
</form>
</body>
</html>

October 4, 2012 at 10:18 PM


the additional operator already done but i still have problem with multiplication operator...when i times 1 by 2, it will get answer 0.5...









Related Pages:
cannot do the additional operator
cannot do the additional operator  i got problem with additional and multiplication operator...please anyone help me <html> <head>... text field var operator = formCalculator.operator.value; //get input from first
What does the delete operator do?
What does the delete operator do?  What does the delete operator do
What does the delete operator do?
What does the delete operator do?  What does the delete operator do
cannot find symbol method nextchar()??
cannot find symbol method nextchar()??  import java.util.Scanner; public class Calc5{ public static void main(String args[]){ Scanner... operand1, operand2 and operator(+,-,x,/)"); int a = obj.nextInt
Cannot assign an ArrayList to an empty ArrayList
Cannot assign an ArrayList to an empty ArrayList  I have a java file, in which a method returns an ArrayList. This ArrayList is supposed to contain...; } FoundStudents.jsp I want to do something like this: ArrayList<Student>
JSP cannot find symbol error - JSP-Servlet
JSP cannot find symbol error  Suppose-- we created 'a.jsp' in which we make a database connection... how to retrieve 'new' here... If I want to access the 'new' string within the form what should i do???  
Appendix A. Additional materials
 Appendix A. Additional materialsPrev Part II. Appendixes Next    Appendix A. Additional materialsSource code ibm-287.code.zip    
php do while break
php do while break   receiving a Fatal saying cannot break/continue.. please suggest. Thank U
Java error cannot find symbol
Java error cannot find symbol       The java error cannot find symbol occurred when a Compiler... do not Imported the class name. In this Tutorial we want to describe you a code
JAVA leftshift operator add 1 instead of 0
JAVA leftshift operator add 1 instead of 0  Hi Guys, I have a task to do. If I have some some int variable and If I apply left shift operator...: 01011 2nd time left shift: 010111 So, the value should be 23. How do I do
PHP Array Operator
Array Operators: In PHP there are many operators are available which works on more than one array, to get union of two arrays, to check the identity, equality etc. '+' operator is used to get the union of two arrays
JPA CriteriaBuilder - How to use ?IN? comparison operator
please help me how to convert the following codes to using "in" operator... "in". ***I also tried to search using JPA CriteriaBuilder - "in" method but cannot find... of User that I need to put inside IN operator CriteriaBuilder builder
AND operator in hibernate.
AND operator in hibernate.  How to use AND operator in hibernate
OR operator in hibernate.
OR operator in hibernate.  How to use OR operator in hibernate
What is the % operator?
What is the % operator?   Hi, What is the % operator? thanks
What do you mean by Serialized?
What do you mean by Serialized?  What do you mean by Serialized?   Hi, It is the part of the isolation level , Its bassically use for the Data read by the current transaction cannot be changed by another transaction
While and do-while
While and do-while      ..., it cannot define any static members itself. Objects that are instances... inner classes, it cannot access any instance variables in the enclosing class
Method Invocation
; Without methods, an object cannot do anything. When an object calls... in their declarations. They should be invoked with the class name, and they do not need... programming language objects play a crucial role. Objects need methods to do something
Java operator
Java operator  What are the legal operands of the instanceof operator
Java operator
Java operator  What is the difference between the prefix and postfix forms of the ++ operator
Java operator
Java operator  Which Java operator is right associative
like operator
like operator  how to select exact value using like operator in php
Java error cannot read
Java error cannot read       The Java error cannot read occurred when a programmer do... a method .get Year ( ).On execution the code show you an error Java Error cannot
What do you mean by Repeatable Read?
What do you mean by Repeatable Read?  What do you mean by Repeatable... read by a SELECT statement cannot be changed; however, if the SELECT statement..., the dirty reads and nonrepeatable reads cannot occur. It means that locks will be placed
LIKE Operator
LIKE Operator       The LIKE operator is used for searching  a specified pattern in the column. In this example we will show you how to use the Like operator to get
how to search for string using LIKE operator instead of integer?
how to search for string using LIKE operator instead of integer?  ... in itemid. however, what i want to do is i want the user to search for the itemname.... and do the same thing by clicking on the hyperlink on itemname column and show
SQL IN Operator
SQL IN Operator       SQL IN Operator helps you to specify multiple values in a WHERE Clause... IN Operator. In this example, we create a table 'Stu_Table'. The create
What is the difference between the Boolean & operator and the && operator?
What is the difference between the Boolean & operator and the && operator?   Hello, What is the difference between the Boolean & operator and the && operator? thanks
Write a program named InternetCharge_YourLastName that do the following:
Write a program named InternetCharge_YourLastName that do the following: .... Additional hours are $1.00 per hour. Package B: For $24.95 per month 50 hours of access are provided. Additional hours are $1.00 per hour. Package C: For $39.95
cannot connect to database - JDBC
cannot connect to database  Iam using eclipse in my system ,when connecting the database mysql version 5.0 to the eclipse iam getting an error as ""Creating connection to mysql has encountered a problem.Could not connect to mysql
The do Keyword
The do Keyword        ... are reserved for a Java program. The do is a Java keyword, that may not be used as identifiers i.e. you cannot declare a variable or class with this name
combobox cannot be resolved in JavaFX
combobox cannot be resolved in JavaFX  I want to design one application with a combobox containing items. and while selecting i want to give user autocomplete suggestion. but while doing this combobox is not getting resolved. i
Java Bitwise Operator
Java Bitwise Operator       In computer, the bitwise operators as their name suggests actually work... to represent negative integers. You cannot use these operators with floating-point
PdfCopyFields cannot be resolved - Java Beginners
PdfCopyFields cannot be resolved   Trying to concatenate PDF files. I downloaded the example from PdfCopyFields cannot be resolved but other
PdfCopyFields cannot be resolved - Java Beginners
PdfCopyFields cannot be resolved  PdfCopyFields cannot be resolved but other classes in the iText-2.1.0.jar are resolved. Any suggestions? Thanks
System.out.println cannot be written inside a class
System.out.println cannot be written inside a class  why System.out.println cannot be written inside a class
Cannot find tag library descriptor
Cannot find tag library descriptor  Cannot find tag library descriptor...? How to resolve in struts in eclipse
Using java script do login form having fields with condition.
Using java script do login form having fields with condition.  Need... conditions of each field should appear. ex :*First name cannot be empty Last Name cannot be empty Email id cannot be empty Password Cannot Be Empty Conform Password
c++ operator overloading
c++ operator overloading  What is operator overloading? and what is mean by overloading?? Can anyone please explain the concept in regards to C
Java 'or' operator
Java 'or' operator       OR operator is a kind of a conditional operators, which is represented... boolean expressions. The OR operator (|) is similar to the Conditional-OR operator
why we use ^ operator in sql, and what is the meaning of that operator?
why we use ^ operator in sql, and what is the meaning of that operator?  why we use ^ operator in sql, and what is the meaning of that operator
java.lang.IllegalArgumentException: node to traverse cannot be null!
java.lang.IllegalArgumentException: node to traverse cannot be null!  Can Any body help me out regarding the above exception in Hibernate HQL
PHP Concatenation Operator
PHP Concatenation Operator  Hi friends, Can any one guide me how to use the concatenation string operator in PHP
cannot find symbol - Java Beginners
cannot find symbol  public class Areatest { public static void main(String[]args) { Figure[]figures={new Triangle(2.0,3.0,3.0),new Rectangle(4.0,6.0),new Square(5.0)}; for(int i=0;i
java.lang.IllegalArgumentException: node to traverse cannot be null!
java.lang.IllegalArgumentException: node to traverse cannot be null!  Hi, I am new to Hibernate. I am facing the problem java.lang.IllegalArgumentException: node to traverse cannot be null! while updating a row. The code
Java Questionmark operator
;  The only ternary (i.e. takes three values) operator in Java is the conditional operator.  Syntax: boolean-expression... This operator returns one of two values depending on a third value
ls: cannot access >: No such file or directory
ls: cannot access >: No such file or directory  import java.io.BufferedReader; import java.io.InputStreamReader; public class Example...: cannot access >: No such file or directory error is displayed .No f.txt
SQL BETWEEN Operator
SQL BETWEEN Operator       The SQL Between Operator works where you want to select a range of data between two values. In SQL, the BETWEEN operator is used to select a range
org.apache.struts.action.ActionMessage cannot be cast to org.apache.struts.action.ActionError - Struts
org.apache.struts.action.ActionMessage cannot be cast...: org.apache.struts.action.ActionMessage cannot be cast to org.apache.struts.action.ActionError... java.lang.ClassCastException: org.apache.struts.action.ActionMessage cannot

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.