rg_backend_academy/lecture_3/hello-world-node/arithmetic-mean.js

16 lines
481 B
JavaScript

import prompt from "prompt-sync";
const promptSync = prompt();
// Function to calculate the arithmetic mean of two numbers
function calculateAverage(a, b) {
return (a + b) / 2;
}
const number1 = Number(promptSync("Enter the first number: "));
const number2 = Number(promptSync("Enter the second number: "));
// Calculate and display the result
const average = calculateAverage(number1, number2);
console.log(`The arithmetic mean of ${number1} and ${number2} is ${average}.`);