How to Input Numbers in Java
Using numbers in Java is part of the process in creating an application that performs numerical calculations. You must first create a Java variable that you set with the proper data type. You can create an integer whole number or a decimal number in Java. After you set up the variable, you input a number. The variable represents memory space in which the number value is contained.
Instructions
-
-
1
Right-click the Java source code file you want to use to create the numeric values. Click "Open With," then click the Java compiler in the list of programs.
-
2
Create the variable. The following code creates an integer and decimal variable:
int myinteger = 0;
float mydecimal = 0.00;
In this example, the initialized value is set to zero.
-
-
3
Input a number for each variable. The following code assigns numbers to the variables created in step two:
myinteger = 5;
mydecimal = 5.55;
-
1