Computer Science, asked by abdulrehman92, 10 months ago

the space below, write a program to calculate the product and average of 4 numbers using INPUT
statements and print the product and average.​

Answers

Answered by prashantrohilla32
1

Answer:

import java.util.Scanner;

public class Main

{

public static void main(String[] args) {

    Scanner sc=new Scanner(System.in);

    int []a=new int[4];

       int b;

       int product=1;

       double ave=0;

       double average;

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

       for(int i=0;i<a.length;i++)

       {

           a[i]=sc.nextInt();

       }

       

       for(int j=0;j<a.length;j++)

       {

           b=a[j];

           product=product*b;

           ave=ave+a[j];

       }

       average=ave/4;

       System.out.println("Product= "+product+" and average= "+average);

}

}

Explanation:

Attachments:
Similar questions