Computer Science, asked by mannatsonkar1, 2 months ago

Write a program to accept 5 numbers and find their sum and average.​

Answers

Answered by ruby932
0

Explanation:

public static void main(String[] args)

{

int i,n=0,s=0;

double avg;

{

System.out.println("Input the 5 numbers : ");

}

for (i=0;i<5;i++)

{

Scanner in = new Scanner(System.in);

n = in.nextInt();

s +=n;

}

avg=s/5;

System.out.println("The sum of 5 no is : " +s+"\nThe Average is : " +avg);

}

}

Answered by ManasviMG
0

Result ^

Answer:

import java.util.Scanner;

public class JavaExcercise {

public static void main(String[] args)

{

int i,numbers=0,sum=0;

double avg;

{

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

}

for (i=0;i<5;i++)

{

Scanner in = new Scanner(System.in);

numbers = in.nextInt();

sum +=numbers;

}

avg=sum/5;

System.out.println("The sum of 5 no is : " +sum+"\nThe Average is : " +avg);

}

}

Attachments:
Similar questions