Wednesday, 11 November 2020

Java Program to add 2 Numbers input by the user using Scanner Class

import java.util.*; 

public class Sum_scanner 

{

public static void main(String args[]) 

{

Scanner in=new Scanner(System.in);

int N1,N2,Sum;

System.out.println("Enter 2 Numbers");

N1=in.nextInt();

N2=in.nextInt();

Sum=N1+N2;

System.out.println("The Sum of "+N1+" and "+N2+" is "+Sum);

}

}

No comments:

Post a Comment

Java Program to count the total number of characters in a string

 //Java Program to count the total number of characters in a string import java.util.*; public class CountChars {     public static void mai...