Average 3 beeCrowd 1040 URI solution C Python programming alpha codist solved problem bee all easy weights formula aluno approvado how to calculate ?
Average 3
The formula is:
- Take input.
- Get the average of n1,n2,n3, and n4 with the formula: (n1*2+n2*3+n3*4+n4*1)/10 (Her 2,3,4 and 1 multiplied with the numbers are weights.
- Print the value of media.
- Check and print the conditions for "Aluno aprovado." and "Aluno reprovado.". Then check the conditions for In exam students.
- If the student is in an exam, print "Aluno em exame." then take another input and calculate the average again. This time just add media and e1 and divide that by 2.
- Now again check the conditions for In exam student and print "Aluno aprovado." or "Aluno reprovado" accordingly.
The solution in C:
#include <stdio.h>
int main() {
double n1,n2,n3,n4,e1;
scanf("%lf %lf %lf %lf",&n1,&n2,&n3,&n4);
double media = (n1*2+n2*3+n3*4+n4*1)/10;
printf("Media: %0.1f\n",media);
if(media>=7.0) printf("\n");
else if(media<5.0) printf("Aluno reprovado.\n");
else if(5.0<=media<=6.9){
printf("Aluno em exame.\n");
scanf("%lf",&e1);
printf("Nota do exame: %0.1f\n",e1);
double media_final = (media+e1)/2;
if(media_final>=5.0){
printf("Aluno aprovado.\n");
} else if(media_final<5){
printf("Aluno reprovado\n");
}
printf("Media final: %0.1f\n",media_final);
}
return 0;
}
The solution in Python:
n1,n2,n3,n4 = map(float, input().split())
media = (n1*2+n2*3+n3*4+n4*1)/10;
print("Media: %0.1f"%media);
if media>=7.0:
print("Aluno aprovado.")
elif media<5.0:
print("Aluno reprovado.")
elif 5.0<=media<=6.9:
print("Aluno em exame.")
e1 = float(input())
print("Nota do exame: %0.1f"%e1)
media_final = (media+e1)/2
if media_final>=5.0:
print("Aluno aprovado.")
elif media_final<5:
print("Aluno reprovado")
print("Media final: %0.1f"%media_final)
COMMENTS