Wednesday, 7 February 2018

Java Program to accept data through keyboard

import java.util.*;
import java.io.*;

class input 
{
 public static void main (String args[]) throws Exception
 {
   int i;
   Scanner sc=new Scanner(System.in);
   System.out.println("enter a number");
   i=sc.nextInt();
   System.out.println("entered number is:"+i);
 
   BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
   System.out.println("enter a statement");
   String s=br.readLine();
   System.out.println("enter line is:"+s);
}
}

Output:
enter a number
10
entered number is:10
enter a statement
we are engineers
enter line is:we are boys

No comments:

Post a Comment