-
Notifications
You must be signed in to change notification settings - Fork 1
/
1040.js
26 lines (18 loc) · 1.57 KB
/
1040.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// Read four numbers (N1, N2, N3, N4), which one with 1 digit after the decimal point, corresponding to 4 scores obtained by a student. Calculate the average with weights 2, 3, 4 e 1 respectively, for these 4 scores and print the message "Media: " (Average), followed by the calculated result. If the average was 7.0 or more, print the message "Aluno aprovado." (Approved Student). If the average was less than 5.0, print the message: "Aluno reprovado." (Reproved Student). If the average was between 5.0 and 6.9, including these, the program must print the message "Aluno em exame." (In exam student).
// In case of exam, read one more score. Print the message "Nota do exame: " (Exam score) followed by the typed score. Recalculate the average (sum the exam score with the previous calculated average and divide by 2) and print the message “Aluno aprovado.” (Approved student) in case of average 5.0 or more) or "Aluno reprovado." (Reproved student) in case of average 4.9 or less. For these 2 cases (approved or reproved after the exam) print the message "Media final: " (Final average) followed by the final average for this student in the last line.
const n1 = 2.0;
const n2 = 4.0;
const n3 = 7.5;
const n4 = 8.0;
const average = (n1 * 2 + n2 * 3 + n3 * 4 + n4 * 1) / (2 + 3 + 4 + 1);
console.log(average);
if (average >= 7.0) {
console.log("Approved Student");
} else if (average < 5.0) {
console.log("Reproved Student");
} else if (5.0 <= average <= 6.9) {
console.log("In exam student");
const score = 6.4;
const examScore = (score + average) / 2;
console.log(examScore);
}