Program that calculates the average of three notes discarding the note with the lowest value between n1 and n2

Programa que calcula a média de três notas descartando menor nota entre N1 e N2
Program that calculates the average of three grades discarding the lowest grade between N1 and N2

In the 1st semester of 2012, in the TSIN course at Uninove, the teacher asked for a program that calculated the average of three grades for a student. The program was written in C on DEV C++.

However, in the first two semesters, the average depends on the following criterion: Discarding the lowest grade between grades N1 and N2, for example:

  • Grade 1 = 7
  • Grade 2 = 10
  • Grade 3 = 8

The lowest score between N1 and N2 is discarded, which in this case is the score Note 1 = 7, so I take the highest score between N1 and N2, I add it to Note 3 and then divide by 2.

Below is the Program that calculates the average of three grades by discarding the grade with the lowest value between n1 and n2

Download Program that calculates the average of three grades by discarding the grade with the lowest value between n1 and n2

Here is the source code of the Program that calculates the average of three grades, discarding the grade with the lowest value between n1 and n2

#include #include main(){ char op; do{ float n1=11,n2=11,n3=11, nm, mean; /* n1 = grade AV1, n2 = grade AV2, n3 = grade AV3, nm = higher grade between grade N1 and N2, average = final average */ printf("\tFabio Bmed TSIN Uninove - www.fabiobmed.com.br\ n\n\tProgram calculates average of 3 grades\n\tIn this calculation the lowest grade between N1 2 N2 is disregarded\n\n\n"); //NOTE 1 while((n1>10) || (n1<0)){ printf("\tEnter the first note: "); scanf("%f",&n1); if ((n1>10) || (n1<0)){ printf("\tIncorrect grade. Please enter a grade between 1 and 10:\n\n"); } else{ break; } } //NOTE 2 while((n2>10) || (n2<0)){ printf("\tEnter the second note: "); scanf("%f",&n2); if ((n2>10) || (n2<0)){ printf("\tIncorrect grade. Please enter a grade between 1 and 10:\n\n"); } else{ break; } } if ( n1 > n2 ){ nm = n1; } else{ nm = n2; } //NOTE 3 while((n3>10) || (n3<0)){ printf("\tEnter the third note: "); scanf("%f",&n3); if ((n3>10) || (n3<0)){ printf("\tIncorrect grade. Please enter a grade between 1 and 10:\n\n"); } else{ break; } } mean=(nm+n3)/2; printf("\n\tNote 1: %.2f \n\tNote 2: %.2f \n\tNote 3: %.2f \n\n\tThe media e: %.2f\n\n",n1, n2,n3,average); printf("\tDo you want to calculate a new average? Y - Continue | N - Exit: "); getchar(); scanf("%c",&op); system("cls"); } while(op == 's'); }

I thank the student VALTER BEZERRA LIMA JUNIOR:

Your application calculates the average of 03 grades. To meet the average calculation in our case, it would need a small modification, discarding the lowest of the three grades and dividing the sum of the two highest by 2 (SUM >=6 APPROVED)

and to professor FRANCISCO CARLOS DANTAS

The correct criterion for calculating the final average takes into account the two best grades.

Which reminded me of the detail of disregarding the lowest grade between N1 and N2.

 1,075 Total Visualizações,  4 Visualizações Hoje

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.