Beecrowd 1040 Average 3 Solution
Introduction
Beecrowd is a well-known site among competitive programmers focused on the enhancement of their problem-solving capacity. Europe, with all its resources, helps programmers perfect various algorithms and coding strategies typical to coding contests and interviews. Many users face problems that fall under this category, for instance, Beecrowd 1040: Average 3. In this section, we will analyze the problem in detail, figure out how to solve it, and what code is necessary in order to achieve it.
Understanding Beecrowd 1040: Average 3
Without jumping straight in to the code, it is important first to know what exactly Beecrowd 1040 is all about. It requires the students to find out their average score from four grades and decide if they succeeded or failed, but it also includes some re-examination if necessary.
Problem Statement Overview
One appropriate statement of the problem is exhibition 3 of Beecrowd 1040. In A496 the student has to construct several parameters based on four different examination scores for the student only.
Input and Output Requirements
Input: There are four floating point numbers each for every student’s score.
Output: It is the average as computed and the status of the student and if retaking the exam was needed it results.
Problem Deconstruction
Clarification of the Grading System
A four-grade system is adopted. They include N1, N2, N3, and N4. Each of the grades has its own weight:
N1 has a weight of 2
N2 has a weight of 3
N3 has a weight of 4
N4 has a weight of 1
How the Average is Calculated
Beecrowd 1040 Average 3 Solution in C
#include <stdio.h> int main() { float a, b, c, d, e, i, j, k; double avg, avrg; scanf("%f %f %f %f", &a, &b, &c, &d); avg = ((a*2) + (b*3) + (c*4) + d) / 10; printf("Media: %.1lf\n", avg); if ( avg < 5.0 ){ printf("Aluno reprovado.\n"); } else if( avg >= 7.0 ){ printf("Aluno aprovado.\n"); } else{ printf("Aluno em exame.\n");//Beecrowd 1040 Average 3 Solution scanf("%f",&e); printf("Nota do exame: %.1f\n",e); avrg = (avg+e) / 2; if ( avrg >= 5.0 ){ printf("Aluno aprovado.\n"); } else {printf ("Aluno reprovado.\n"); } printf("Media final: %.1lf\n",avrg); } return 0; }
Beecrowd 1040 Average 3 Solution in C++
#include <iostream>
#include <iomanip>
using namespace std;
int main() {
float a, b, c, d, e;
double avg, avrg;
cin >> a >> b >> c >> d;
avg = ((a * 2) + (b * 3) + (c * 4) + d) / 10;
cout << fixed << setprecision(1);
cout << "Media: " << avg << endl;
if (avg < 5.0) {
cout << "Aluno reprovado." << endl;
} else if (avg >= 7.0) {
cout << "Aluno aprovado." << endl;
} else {
cout << "Aluno em exame." << endl;
cin >> e;
cout << "Nota do exame: " << e << endl;
avrg = (avg + e) / 2;
if (avrg >= 5.0) {
cout << "Aluno aprovado." << endl;
} else {
cout << "Aluno reprovado." << endl;
}
cout << "Media final: " << avrg << endl;
}
return 0;
}
Beecrowd 1040 Average 3 Solution in Python
a, b, c, d = map(float, input().split())
avg = ((a * 2) + (b * 3) + (c * 4) + d) / 10
print(f"Media: {avg:.1f}")
if avg < 5.0:
print("Aluno reprovado.")
elif avg >= 7.0:
print("Aluno aprovado.")
else:
print("Aluno em exame.")
e = float(input())
print(f"Nota do exame: {e:.1f}")
avrg = (avg + e) / 2
if avrg >= 5.0:
print("Aluno aprovado.")
else:
print("Aluno reprovado.")
print(f"Media final: {avrg:.1f}")
Wrap Up
Beecrowd 1040: Average 3 solution is excellent practice on weighted averages, if statements, and floating point numbers. In the present guide, you should be able to gradually work out the solution to the problem provided and you will be able to produce correct and optimal code.
Hey people!!!!!
Good mood and good luck to everyone!!!!!
Hey people!!!!!
Good mood and good luck to everyone!!!!!
Hey people!!!!!
Good mood and good luck to everyone!!!!!
Thanks for sharing. I read many of your blog posts, cool, your blog is very good.