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 to create immutable class in java?

by making that class final


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(); } }


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.


How you make a project in java?

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


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); } } }


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.


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); } }


What class can you extend to create a simple class that provides remote methods using RMI in java?

Remote