Computer Science, asked by aman9495, 6 months ago

write a program in java to add five number​

Answers

Answered by riyatantiya28
1

Explanation:

public class add

{

public static void main(String args[])

{

int a=1,b=2,c=3,d=4,e=5; //You can take any value

int f=a+b+c+d+e;

System.out.println(f);

}

}

If you want to take input:

import java.util.*;

public class add

{

public static void main(String args[])

{

Scanner in=new Scanner(System.in);

System.out.println("Enter the five numbers:");

int a,b,c,d,e;

a=in.nextInt();

b=in.nextInt();

c=in.nextInt();

d=in.nextInt();

e=in.nextInt();

int s;

s=a+b+c+d+e;

System.out.println("Sum="+s);

}

}

Hope it helps! :)

Similar questions