Given 4 numbers (passed in as parameters) write a function that returns the average of these numbers please write this with a function in java form example function.somthing() and make an html file of the version as well please somthing like this function Numbers() { for (let i = 1; i <= 10; i++) { console.log(i);} } i just need somethig simple like function() var a = (make the user put a random nuber in) var b = (make the user put a random nuber in) var c = (make the user put a random nuber in) var d = (make the user put a random nuber in) return a+b+c+d/4
Given 4 numbers (passed in as parameters) write a function that returns the average of these numbers
please write this with a function in java form example function.somthing()
and make an html file of the version as well please
somthing like this
function Numbers() {
for (let i = 1; i <= 10; i++) {
console.log(i);} }
i just need somethig simple like
function()
var a = (make the user put a random nuber in)
var b = (make the user put a random nuber in)
var c = (make the user put a random nuber in)
var d = (make the user put a random nuber in)
return a+b+c+d/4
WITH OUT PYTHON PLZ WITHOUT THIS CODE below
import java.util.Scanner;
public class AverageClass {
public static void main(String[] args) {
int a, b, c, d;
Scanner sc = new Scanner(System.in);
System.out.print("Enter 4 numbers : ");
a = sc.nextInt();
b = sc.nextInt();
c = sc.nextInt();
d = sc.nextInt();
System.out.println("Average : " + average(a, b, c, d));
}
static float average(int a, int b, int c, int d) {
float sum;
sum = a + b + c + d;
return sum / 4;
}
}
Trending now
This is a popular solution!
Step by step
Solved in 5 steps with 7 images