write the following methods and provide a program to test them.
double average(double x, double y, double z), returning the average of the arguments.
in java 1.7
import java.util.Scanner; public class AverageThree { public static double average(double x, double y, double z) { return (x + y + z) / 3.0; } public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.print("Enter three numbers: "); double x = in.nextDouble(); double y = in.nextDouble(); double z = in.nextDouble(); System.out.println("Average of three numbers is " + average(x, y, z)); } }
Get Answers For Free
Most questions answered within 1 hours.