Monday, 27 April 2020

Input from user in Java programming


Write a program to take any two values from the user and add the values and print the result . 


import  java.util.*;         // Package Name 

class Abc
{
            public static void main(String args[])
            {
                   int a , b , c ;         
                  Scanner sk=new Scanner(System.in) ;     
                  System.out.print("Enter Value 1  = ") ;
                  a = sk.nextInt() ;   
                  System.out.print("Enter Value 2  = ") ;
                  b = sk.nextInt() ;
                  c = a+b ;
                  System.out.println("Addition is " +c) ;
            }
}

========================================================

For video search my new YouTube channel   :    SK Skill India









No comments:

Post a Comment