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);
}
}
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.
by making that class final
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(); } }
You can use the full name of the class. In your case example: java.util.Scanner scanner = new java.util.Scanner(System.in);
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++;}}}
We can create a exception sub class by extending Exception class available 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.
You create a text file with a .java extension. Then you put a proper class definition.
You need to use File class to create file in java and than Reader class implementation such as BufferedReder to read content.
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); } }
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); } } }
Remote