Computer Science, asked by jose69, 8 months ago

can u pls help me write a java program to add 5 different numbers... ​

Answers

Answered by RABiswas123
1

class add

{

public void main (int a , int b, int c, int d, int e)

{

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

System.out.println("The sum of the five numbers = " + sum);

}

}

Answered by IamGenesis
1

Answer:

import java.util.Scanner;

class Add{

public static void main(String[] args){

Scanner sc = new Scanner (System.in);

System.out.println("Enter 5 numbers");

int sum = 0;

for(int i = 1; i<=5; i++){

sum += sc.nextInt();

}

System.out.println("Sum is "+sum);

}

}

Similar questions