# Average, Sum, and Product in Java Using BigDecimal

Feb 3, 2021

Write a Java program to solve the average, sum and product of three numbers using double data type and big decimal.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me at the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My mobile number here in the Philippines is 09173084360.

Program Listing

``````import java.util.Scanner;
import java.math.*;

/**
* @author Jake R. Pomperada, MAED-IT, MIT
* Bacolod City, Negros Occidental Philippines
*
*/

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub

Scanner scan = new Scanner(System.in);

System.out.println("\n");
System.out.println("\tAverage, Sum, and Product in Java Using BigDecimal");
System.out.println("\n");
System.out.print("\tEnter the First number: ");
double num1 = scan.nextDouble();
System.out.print("\tEnter the Second number: ");
double num2 = scan.nextDouble();
System.out.print("\tEnter the Third number: ");
double num3 = scan.nextDouble();
scan.close();

avg = new BigDecimal(average(num1, num2, num3));
add =  new BigDecimal(sum(num1, num2, num3));
multiply =  new BigDecimal(product(num1, num2, num3));

avg_display = avg.doubleValue();
multiply_display = multiply.doubleValue();

System.out.println("\n");
System.out.print("\tAverage of these numbers :"
+ avg_display + "\n");
System.out.print("\tSum of these numbers :"
System.out.print("\tProduct of these numbers :"
+  multiply_display+"\n");
System.out.println("\n");
System.out.println("\tEnd of Program");
System.out.println();
}

public static double average(double a, double b, double c)
{
return (a + b + c) / 3;
}

public static double sum(double a, double b, double c)
{
return (a + b + c);
}

public static double product(double a, double b, double c)
{
return (a * b * c);
}
}
``````