JavaScript Program Calculates Average of Three Numbers Entered by User Using a Function and Displays Result.
Sure! Here's a simple JavaScript program for class 7:
```javascript // Program to calculate the average of three numbers
// Function to calculate the average function calculateAverage(num1, num2, num3) { return (num1 + num2 + num3) / 3; }
// Taking input from the user let number1 = parseInt(prompt("Enter the first number:")); let number2 = parseInt(prompt("Enter the second number:")); let number3 = parseInt(prompt("Enter the third number:"));
// Calculating the average let average = calculateAverage(number1, number2, number3);
// Displaying the result console.log("The average of the three numbers is: " + average); ```
This program calculates the average of three numbers entered by the user. It defines a function `calculateAverage` that takes three numbers as input and returns their average. It then prompts the user to enter three numbers, calculates their average using the `calculateAverage` function, and displays the result using `console.log`.