by Dinesh Thakur Category: Introduction to Java

In this Example we Reading the numbers and string in the class Scanner becomes analogous to reading string. In this example, the two numbers are read from the console, results printed on the screen formatted output.

import java.util.*;
class InputDemo
               public static void main (String args [ ])
                int a,b;
                double pi;
                String name;
                Scanner s=new Scanner(;
                System.out.println("Enter thevalue of a & b ");
                a=s.nextInt( );
                b=s.nextInt( );
                System.out.println("Enter the value of pi ");
                pi=s.nextDouble( );
                System.out.println("Enter the your name ");
                System.out.println("The value of a = "+a);
                System.out.println("The value of b = "+b);
                System.out.println("The value of pi = "+pi);
                System.out.println("Name = "+name );

About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.C.A, MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.