Program to addition of n number using Scanner class in java programming .

Program to addition of n number using Scanner class  in java programming :

import java.lang.*;
import java.io.*;
import java.util.*;
class AddnNumber
{
public static void main(String args[])
{
int num,value,i,sum=0;
Scanner s=new Scanner(System.in);
System.out.println("a3programming.blogspot.com");
System.out.println("Enter number howmany number do you want addition :\t");
num=s.nextInt();
System.out.println("Enter numbers :");
for(i=1; i<=num; i++)
{
value=s.nextInt();
sum=sum+value;

}
System.out.println("Result :"+sum);
}
}
Expected output is:


Post a Comment

0 Comments