Write a program in java to demonstrate taking input from user?

import java.util.Scanner;

class Input

{

                public static void main(String arg[])

                {

                                Scanner in=new Scanner(System.in);

                                System.out.print("Enter String ");

                                String s=in.nextLine();

                                System.out.print("Enter First Number ");

                                int a=in.nextInt();

                                System.out.print("Enter Second Number ");

                                int b=in.nextInt();

                                int c=a+b;

                                System.out.println("Result is "+c);

                                System.out.println(s);

                }

}

Taking Input In JAVA.PNG

, , , , , , , , , ,

Leave a Reply