Answers for "how to take input of two numbers in java"

34

how to take input in java

Scanner sc = new Scanner(System.in);  // Create a Scanner object
String userName = sc.nextLine();//read input string
int age = sc.nextInt(); //read input integer
long mobileNo = sc.nextLong(); //read input long
double cgpa = sc.nextDouble(); //read input double
System.out.println(userName);//output
Posted by: Guest on May-03-2020
2

how to get user input in java

import java.util.*;  
class UserInputDemo   
{  
public static void main(String[] args)  
{  
Scanner sc= new Scanner(System.in);    //System.in is a standard input stream  
System.out.print("Enter first number- ");  
int a= sc.nextInt();  
System.out.print("Enter second number- ");  
int b= sc.nextInt();  
System.out.print("Enter third number- ");  
int c= sc.nextInt();  
int d=a+b+c;  
System.out.println("Total= " +d);  
}  
}  
Posted by: Guest on December-09-2020
0

how to get multiple integer input in java

String input = scanner.nextLine();    // get the entire line after the prompt 
String[] numbers = input.split(" "); // split by spaces
Posted by: Guest on July-02-2020
0

how to get multiple integer input in java

Scanner scanner = new Scanner(System.in);

    while(scanner.hasNext())
    {
        System.out.println(scanner.nextInt());
    }
Posted by: Guest on July-02-2020

Code answers related to "how to take input of two numbers in java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language