Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

Adding in java using user input

import java.util.Scanner; //import build in library for take input from user
public class data {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in); // making object for scan
        System.out.println("Addition of two numbers");
        System.out.println("Enter Number 1: "); // enter num1
        int num1 = (int) scan.nextFloat(); //taking ur answer in float format
        System.out.println("Enter Number 2: "); // same thing
        int num2 = (int) scan.nextFloat(); //same thing
        int result = (int) (num1 + num2); //sum 2 answer that user input before
        System.out.println("Result: " + result); //printing the result

    }

    
}
Comment

PREVIOUS NEXT
Code Example
Java :: java string replace character at position 
Java :: char to unicode java 
Java :: uppercase java 
Java :: start activity for result deprecate 
Java :: fill two dimensional array row by row java 
Java :: java first letter to upper case 
Java :: PathProviderPlugin.java uses unchecked or unsafe operations. 
Java :: java convert date to localdate 
Java :: intellij 
Java :: java Program for Sum of the digits of a given number 
Java :: android java listview clean 
Java :: java base64 
Java :: list of integers in java 
Java :: synchronized java 
Java :: java sum of array elements 
Java :: threads array java 
Java :: setbackground java 
Java :: BST in java 
Java :: java square root 
Java :: java instance of a class 
Java :: radio button in java 
Java :: processing angle between two points 
Java :: retrieving parent element from child aWebelement selenium java 
Java :: how to change tablayout current view position in android 
Java :: how to make priority queue of pairs in java 
Java :: does constructor return any value java 
Java :: java initialize class 
Java :: How to get the nth Fibonacci number code in Java using recursion 
Java :: generic classes in java 
Java :: is java compiled or interpreted 
ADD CONTENT
Topic
Content
Source link
Name
1+9 =