0

ES6 Classes

someone could tell me, what I am making wrong here please? You are making a program so that students are able to calculate their average of 3 exam scores. The given program takes the scores of 3 exams as input and declares the Exams class. Add a static method average() to class Exams, which will take the scores as parameters, and calculate and return the average score rounded to the nearest integer so that the code in main works correctly. Sample Input 74 80 68 Sample Output 74 https://code.sololearn.com/WA21a20a13A8

4th Jun 2021, 8:09 AM
JRAMAHES
JRAMAHES - avatar
2 Answers
+ 1
JRamoneMH Will you please write your code in Sololearn Code Playground and share the link here.
4th Jun 2021, 8:41 AM
AÍąJ
AÍąJ - avatar
0
function main() { var exam1 = parseInt(readLine(), 10); var exam2 = parseInt(readLine(), 10); var exam3 = parseInt(readLine(), 10); console.log(Exams.average(exam1, exam2, exam3)); } class Exams { static average(exam1, exam2, exam3) { // Calculate the average and round it to the nearest integer return Math.round((exam1 + exam2 + exam3) / 3); } }
6th Oct 2023, 1:33 PM
Sina Ghorbanian
Sina Ghorbanian - avatar