to read number from user

to read number from user

1)print the positive equivalent of the number 2) check if the no is integer or not 3) find the square root of the number 4) find the cube of the number

View Answers

March 12, 2011 at 12:53 PM

<html>
<script>
function check(){
var n=document.getElementById("num").value;
if(!isNaN(n)){
alert("Entered value is integer!");
}
else{
alert("Entered value is not an integer!");
}
var num=parseInt(n);
alert("Square root of a number: "+Math.sqrt(num));
var cube=num*num*num;
alert("Cube of a number: "+cube);

}
</script>
Enter Number<input type="text" id="num"><input type="button" value="Check" onclick="check();">
</html>









Related Tutorials/Questions & Answers:
to read number from user
to read number from user  1)print the positive equivalent of the number 2) check if the no is integer or not 3) find the square root of the number 4) find the cube of the number
How to read user input in C++
How to read user input in C++  How can i get an input from the users in C++?   You can use the standard input "cin" to get the input from user.. For example: int age; cin >> age
Advertisements
from number to word
from number to word  i want to know weather there is any method that can be use in changing value from number to word. Example if i write ten thousand, it will automatically be written as 10000.   Java convert number
Read user input in Java using Scanner
and Scanner class is one of them. Scanner class can be used to read user input from... are explaining the use of Scanner class in Java which can be used to read user input from console. Our sample program asks user to enter name and then age, user
Read from file java
Read from file java  How to Read from file java? What is the best method for a text file having a size of 10GB. Since i have to process the file one line at a time so tell me the very best method. Thank you
accept integer from user
accept integer from user  Write an Java application that accepts 100 integer numbers from a user. The input should be in the range of 1-200. Error message needs to be displayed if user entered input which is not in this range
How to read from stdin in python
How to read from stdin in python  Hi, I am writing a program in python which is suppose to take input from user. In Java it was easy..., In Python also you can easily take input from user. I will show you two examples
how to read from dictionary c
how to read from dictionary c  how to read elements from dictionary in c programming
Read from a window - Java Beginners
Read from a window  HI, I need to open a website and read the content from the site using Java script. Please suggest. Thanks
read data from Excel sheet
read data from Excel sheet  Hi, How to read data from an excel sheet using JSP. Thank you
Read Property file From Jmeter
Read Property file From Jmeter  Hi, I am running web driver script from Jmeter, but while reading property file I am getting "File Not Find Exception". Please tell me how to read ".properties" file from Jmeter
Read Lines from text file
Read Lines from text file  Here's a brief desc of what my Java code does .. I'm using BufferedReader to read lines from a text files and split each... read from the text file and displays the output as desired. Unable to read the rest
Java read lines from file
Java read lines from file  Any code example related to Java read lines from file? In my project there is requirement of reading the file line by line... to read the whole file in one go. So, in my case reading file line by line is only
Read the value from XML in java
Read the value from XML in java  Hi, i have an XML with the following code. I need to get the path("D... the permissions on that file.So how can i read that value. This is little urgent
How to set Messages number to be read in pop3 mail server
How to set Messages number to be read in pop3 mail server  how to set messages number in pop3, i am able to read only 250 mails from my inbox where as my inbox has more than 1000 unread mails, how to read all at once in pop3
How to set Messages number to be read in pop3 mail server
How to set Messages number to be read in pop3 mail server  How to set Messages number to be read in pop3 mail server, i am able to read only 250 mails from my inbox whereas i have more than 1000 unread mails in my in my inbox
print the sum of even number from 1 to 100
print the sum of even number from 1 to 100  how to print the sum of even number from 1 to 100 using for loops? Thanks
read a positive real numbers from highest to lowest
read a positive real numbers from highest to lowest  write a java program that will read a sequence of 10 positive real nos. entered by the user and will print the same numbers in sorted order from lowest to highest using arrays
Read Cookies from Servlet
Read Cookies from Servlet       This section illustrates you how to read cookies from Servlets. The Cookie Class provides an easy way to read Cookies. You can use getCookies() method
autogeneration of a random number and displaying it as a alert message to the user on clicking submit
automatically.But i want this number to be displayed when user click...autogeneration of a random number and displaying it as a alert message to the user on clicking submit  Hi, In my project order purchase system under
error in taking input from user.
error in taking input from user.  //i m having problem inputting the array from user.my program is import java.io.*; class bubble { public static void main(String args[]) { int a[]=new int[20]; int i=0; BufferedReader br=new
Find Second Largest Number from an Array
Find Second Largest Number from an Array This section illustrates you how to find the second largest number from an array. For this purpose, we have allowed... among them. Pulls the largest number out from the array and again check
retrieve value from database on the basis of maximum id number
retrieve value from database on the basis of maximum id number  hi, i want to retrieve value of maximum id number from the database and show that value in jTextField.when the user clicks on the button that maximum id number
how to read values from java in xml?
how to read values from java in xml?  how to read values from java in xml
Read Text file from Javascript - JSP-Servlet
Read Text file from Javascript  plz send the code How to Retrieve the data from .txt file thru Javascript? And how to find the perticular words in that file
read from cmd syntax and open the file
read from cmd syntax and open the file  i have to read the name of the database e.g., "database.txt" file from a cmd syntax and open it: java FindKeys database=db.txt;minjoinrows=integer|all how can i do
read from cmd syntax and open the file
read from cmd syntax and open the file  i have to read the name of the database e.g., "database.txt" file from a cmd syntax and open it: java FindKeys database=db.txt;minjoinrows=integer|all how can i do
read excel file from Java - Java Beginners
read excel file from Java  How we read excel file data with the help of java?  Hi friend, For read more information on Java POI visit to : http://www.roseindia.net/java/poi/ Thanks
read excel data from jsp - JSP-Servlet
read excel data from jsp  Hi how to read excel file from jsp? Excel file is created manually entered data having many sheets? and read the entire...)excel.jsp: Read And Edit Excel File  continue
How to read value from xml using java?
How to read value from xml using java?  Hi All, I want to read value from following xml using java.. In <Line>,data is in format of key and value pair.. i want to read only values..could u plz help me in this?Thanks
read from file and store using hash map
read from file and store using hash map  I was stuck with a java project where I have to read a file with two different concepts and store them differently in hashmap. My data file would be something like Adults: Name, xyz
How to read a line from a doc file
How to read a line from a doc file  How to read a line from a doc file   Hi Friend, To run the following code, you need to download POI library.ADS_TO_REPLACE_1 import java.io.*; import
How to read text from - Java Beginners
How to read text from   How to retrieve text from the images... Does we have any function to get text over the images  Hi Friend, We are providing you a code that will set text over an image using javascript
how to read the .proprties file from struts - Struts
how to read the .proprties file from struts   errpr is :file not found exception:applicationresource.proprties file {system canot find file path"; How to set the file path.  Hi Friend, It seems that you haven't
org.hibernate.MappingException: Could not read mappings from resource:
org.hibernate.MappingException: Could not read mappings from resource: ...: org.hibernate.MappingException: Could not read mappings from resource: hbmxml/login.hbm.xml please...("****************"); Query query = session.createQuery("from Login where id=1
read value from database & alert it is available in database or not
read value from database & alert it is available in database or not  how to read value from text box and alert whether it is available in database...=con.createStatement(); ResultSet rs=st.executeQuery("select * from login
Program to read the text from a file and display it on a JFrame.
Program to read the text from a file and display it on a JFrame.  import javax.swing.*; import java.io.*; import java.lang.*; import java.awt.*; class MegaViewer1 extends JFrame { JTabbedPane jtp1=new JTabbedPane
Could not read mappings from resource: e1.hbm.xml - Hibernate
Could not read mappings from resource: e1.hbm.xml  ... not read mappings from resource: e1.hbm.xml Exception in thread "main...; } } --------------------------------------------- read for more information, http
Read file from the Nth line
Read file from the Nth line Java provides several classes and methods to manipulate file. A file reading, is a common operation. Usually a file is to be read from top to bottom but here we are going  to read a file content from
C file read example
C file read example       This section demonstrates you to read a line from the file. You can see in the given example, we prompt the user to enter the name of the file to read
find the largest number enter by user - Java Interview Questions
find the largest number enter by user  sorry for not stating clearly my question. i want to know how to find the largest number enter by user...(fwriter); for(int i=1; i<=5; i++) { System.out.print("Enter a number
How to read and display data from a .properties file from a jsp page
How to read and display data from a .properties file from a jsp page  I have a .properties file. I have to create a jsp page such that it reads the data from this .properties file and display it in table format. Ex:by using
Count numbers of spaces and number of words from the input string
Count numbers of spaces and number of words from the input string Java In this section, you will learn how to count the number of spaces and words from the string. For this purpose, we have prompted the user to enter the string
How to read and display password from the console
Description: Console class was introduced in jdk 1.6 This class help in taking the input from the console using its readPassword method . Here...;cons.readPassword(format, "Enter", "user",    
Fetch user records from a table in database
Fetch user records from a table in database  Hi. I have a field in database named stages. its datatype is varchar(60). It contains values chennai,trichy,kanchipuram for a single record. I have to retrieve these data from
ask user how many numbers to be inputted and determine the sum and highest number using an array in java
ask user how many numbers to be inputted and determine the sum and highest number using an array in java  ask user how many numbers to be inputted and determine the sum and highest number using an array in java
Read Specific Line from file Using Java
Read Specific Line from file Using Java Here we are going to read a specific line from the text file. For this we have created a for loop to read lines 1 to 10 from the text file. If the loop reached fifth line, the br.readLine() method
java program to insert data into a file and count the number of words from the file???????
java program to insert data into a file and count the number of words from the file???????  java program to insert data into a file and count the number of words from the file
How to hide HTML code from user? - Security
How to hide HTML code from user?  Hi All, I am trying to provide security to my web application. To achieve this I want to restrict user from... through the use of DOM loading the data from another javascript file
Read File from specified path in Java
How to read a file from a specified path in Java? After learning so many.... In this tutorial we are to teach you the steps to read a file from a disk... and interfaces to work with files and directories. If you try to read a file from which

Ads