answersLogoWhite

0

http://javacodespot.blogspot.com/2011/04/java-programming-using-scanner-for-user.html

import java.util.*;

public class ScannerClass

{

public static void main(String[] args)

{

Scanner scan=new Scanner(System.in);

System.out.print("1st num: ");

int num1=scan.nextInt();

System.out.println();

System.out.print("2nd num: ");

int num2=scan.nextInt();

int sum=num1+num2;

System.out.println();

System.out.println("Sum: "+sum);

}

}

User Avatar

Wiki User

14y ago

What else can I help you with?

Related Questions

How do you store fingerprints in java?

Java has no built-in framework for dealing with biometric data, fingerprints included. If you wanted to build your own class, it would be sensible to store the information in the same way your fingerprint scanner passed it on. If the scanner gives you an image, store the image. If the scanner gives you a bunch of numbers, store a bunch of numbers.


How do you get double numbers from keyboard in java?

import java.util.*; public class Example { public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.println("Please enter a Double:"); double numDouble = in.nextDouble(); } }


Java program to arrange any numbers in ascending order using scanner classes?

To arrange numbers in ascending order using Java, you can utilize the Scanner class to read input from the user and then sort the numbers using an array. Here's a simple example: import java.util.Arrays; import java.util.Scanner; public class AscendingOrder { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.print("Enter the number of elements: "); int n = scanner.nextInt(); int[] numbers = new int[n]; System.out.println("Enter the numbers:"); for (int i = 0; i < n; i++) { numbers[i] = scanner.nextInt(); } Arrays.sort(numbers); System.out.println("Numbers in ascending order: " + Arrays.toString(numbers)); scanner.close(); } } This program collects a specified number of integers from the user, sorts them using Arrays.sort(), and then displays the sorted list.


How to create immutable class in java?

by making that class final


How could a program use a class Scanner without importing it in java programming?

You can use the full name of the class. In your case example: java.util.Scanner scanner = new java.util.Scanner(System.in);


How do you create a loop java program that will give the average of numbers?

import java.util.Scanner;public class Ooops{public static void main (String[]args){Scanner kb= new Scanner (System.in);int ave;int ctr=1;while(true){System.out.println("Enter the number");int no = kb.nextInt();ave+=no/ctr;ctr++;}}}


How an exception subclass is created in java explain?

We can create a exception sub class by extending Exception class available in java


What is classes in java?

class is a blueprint which does not have its own existence but it can pass all of its feature to its child classes.


Java code that display even numbers from 0 to 10?

import java.util.*; class even{ public static void main(String[]args){ Scanner cons = new Scanner(System.in); int even; even = cons.nextInt(); if(even % 2 == 0) { System.out.println(even); } } }


How can you create java average calculator..any integer number.using netbeans or notepad plus plus?

import java.util.*; public class avg { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("How many numbers: "); int amount = input.nextInt(); double [] numbers = new double[amount]; double count = 0; double avg; for(int i = 0; i < numbers.length; i++){ System.out.print("Number: "); numbers[i] = input.nextDouble(); count += numbers[i]; } avg = count / amount; System.out.println(avg); } }


How you make a project in java?

You create a text file with a .java extension. Then you put a proper class definition.


Program in Java to create file and copy content of an existing file to it?

You need to use File class to create file in java and than Reader class implementation such as BufferedReder to read content.