cannot do the additional operator

cannot do the additional operator

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 Tutorials/Questions & Answers:
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
Advertisements
What does the delete operator do?
What does the delete operator do?  What does the delete operator do
Appendix A. Additional materials
 Appendix A. Additional materialsPrev Part II. Appendixes Next    Appendix A. Additional materialsSource code ibm-287.code.zip    
ModuleNotFoundError: No module named 'additional-data'
ModuleNotFoundError: No module named 'additional-data'  Hi, My... named 'additional-data' How to remove the ModuleNotFoundError: No module named 'additional-data' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'hashlib-additional'
ModuleNotFoundError: No module named 'hashlib-additional'  Hi, My... named 'hashlib-additional' How to remove the ModuleNotFoundError: No module named 'hashlib-additional' error? Thanks   Hi, In your
OR operator in hibernate.
OR operator in hibernate.  How to use OR operator in hibernate
AND operator in hibernate.
AND operator in hibernate.  How to use AND operator in hibernate
What is the % operator?
What is the % operator?   Hi, What is the % operator? thanks
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
ModuleNotFoundError: No module named 'django-compressor-additional-compilers'
ModuleNotFoundError: No module named 'django-compressor-additional-compilers...: ModuleNotFoundError: No module named 'django-compressor-additional-compilers' How to remove the ModuleNotFoundError: No module named 'django-compressor-additional
ModuleNotFoundError: No module named 'additional-urwid-widgets'
ModuleNotFoundError: No module named 'additional-urwid-widgets'  Hi...: No module named 'additional-urwid-widgets' How to remove the ModuleNotFoundError: No module named 'additional-urwid-widgets' error? Thanks  
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
ternary operator
ternary operator  (Ternary operator) Dearness Allowance= 25% of Basic pay house rent allowance= 15% of basic pay Provident fund= 8.33% of Basic pay Net pay=basic pay+Dearness allowance+house rent allowance Gross pay= Net pay
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
SQL IN Operator
SQL IN Operator       SQL IN Operator helps you to specify multiple values in a WHERE Clause... an example from SQL IN Operator. In this example, we create a table 'Stu
php do while break
php do while break   receiving a Fatal saying cannot break/continue.. please suggest. Thank U
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 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
springbootservletinitializer cannot be resolved to a type
springbootservletinitializer cannot be resolved to a type  Hi, I have a web application and it is giving following error in eclipse: springbootservletinitializer cannot be resolved to a type What dependency should is Add
The import javax.validation cannot be resolved
The import javax.validation cannot be resolved  Hi, I have a web application and due to missing maven dependency it is giving following error in Eclipse: The import javax.validation cannot be resolved. What maven dependency
org.hibernate.validator cannot be resolved error
org.hibernate.validator cannot be resolved error  In Hibernate based application my application is giving following error: org.hibernate.validator cannot be resolved error Program is not compiling due to this error. How
GsonBuilder cannot be resolved to a type
GsonBuilder cannot be resolved to a type  Hi, I am using GsonBuilder in my program and it is giving following compilation error: GsonBuilder cannot be resolved to a type How to solve this? What is the jar file for GsonBuilder
GsonBuilder cannot be resolved to a type
GsonBuilder cannot be resolved to a type  Hi, I am using GsonBuilder in my program and it is giving following compilation error: GsonBuilder cannot be resolved to a type How to solve this? What is the jar file for GsonBuilder
GsonBuilder cannot be resolved to a type
GsonBuilder cannot be resolved to a type  Hi, I am using GsonBuilder in my program and it is giving following compilation error: GsonBuilder cannot be resolved to a type How to solve this? What is the jar file for GsonBuilder
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
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
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
cannot display an arrayList in JSP
cannot display an arrayList in JSP  Hello, My bean is called Zone, i got all Zones from sql Server with Hibernate. in DAO.Class: print("List zones = session.createQuery("FROM Zone").list();"); i want to send this List from
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
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 'or' operator
Java 'or' operator       OR operator is a kind of a conditional operators, which... between the two boolean expressions. The OR operator (|) is similar
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???  
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>
PHP Concatenation Operator
PHP Concatenation Operator  Hi friends, Can any one guide me how to use the concatenation string operator in PHP
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
scala.collection.immutable.map$map1 cannot be cast to java.util.map
scala.collection.immutable.map$map1 cannot be cast to java.util.map  Hi, I am trying to cast the Map in spark java but it throws following error: scala.collection.immutable.map$map1 cannot be cast to java.util.map How to solve
scala.collection.immutable.map$map1 cannot be cast to java.util.map
scala.collection.immutable.map$map1 cannot be cast to java.util.map  Hi, I am trying to cast the Map in spark java but it throws following error: scala.collection.immutable.map$map1 cannot be cast to java.util.map How to solve
scala.collection.immutable.map$map1 cannot be cast to java.util.map
scala.collection.immutable.map$map1 cannot be cast to java.util.map  Hi, I am trying to cast the Map in spark java but it throws following error: scala.collection.immutable.map$map1 cannot be cast to java.util.map How to solve
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
Explain the ternary conditional operator in PHP?
Explain the ternary conditional operator in PHP?  Explain the ternary conditional 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
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
do the following
do the following  write a program to enter the string and do the following 1- count totle number of vowel 2- replace vowel 3- delete the charactor from given value 4- riverce the string 5- convert second word in upercase 6

Ads