Listado de notas y un poco más ¡Practicando con AzulSchool! [ESP-ENG] | C++

Saludos, vuelvo con otro proyecto, del curso que he venido mencionado AzulSchool, en concreto el proyecto número 3. El enunciado pide crear un programa que guarde las notas de N alumnos, con un rango de entre 20 a 30, además de incluir una validación que asegure que se cumpla. Luego añade que el programa debe calcular la suma de todas las calificaciones, mostrar el promedio total del salón, al alumno con mayor nota, el alumno con menor nota y las notas de todos con un rango de -1 a +1, aunque esto último lo cambié a un rango de 0 a 10 para que fuese un poco más local, es decir, en el ámbito universitario es bastante común ese rango por acá, aunque también el de 0 a 20, pero ese último no me agrada tanto.

En cuanto a las librerías incluí las mismas que he usado en todos las publicaciones de esta pequeña serie. El main solo tiene un llamado de función, como es costumbre. Las funciones declaradas se componen de "Is_float()" para la validación de la entrada por teclado (que solo entren números flotantes) y "notes_calculator()" que cumple con los cálculos requeridos. También estuvo "comprobator" y "IsNumberInt", que ya he mencionado varias veces, aunque hubo una pequeña modificación que explico a continuación.

Greetings, I am back with another project, from the course I have been mentioning AzulSchool, specifically project number 3. The statement asks to create a program that stores the grades of N students, with a range of between 20 to 30, as well as including a validation to ensure that it is fulfilled. Then it adds that the program must calculate the sum of all the grades, show the total average of the classroom, the student with the highest grade, the student with the lowest grade and the grades of all with a range from -1 to +1, although this last one I changed it to a range from 0 to 10 so that it was a little more local, that is to say, in the university environment that range is quite common around here, although also the one from 0 to 20, but that last one I don't like so much.

As for the libraries I included the same ones that I have used in all the publications of this small series. The main has only one function call, as usual. The declared functions consist of "Is_float()" for keyboard input validation (that only float numbers enter) and "notes_calculator()" which performs the required calculations. There was also "comprobator" and "IsNumberInt", which I have already mentioned several times, although there was a small modification that I explain below.


Portada post programacion, tech.jpg

Edited with CANVA

Programación c++.png

image.png

image.png

image.png

image.png

Programación c++.png

Para la función "notes_calculator()", tenemos múltiples variables, comenzndo por "n_student" para registrar el número de estudiantes una vez haya sido filtrado con "n_aux", apoyándose en la función "comprobator". En esta ocasión la modifiqué un poco para adecuarla al requerimiento de rango en el número de estudiantes. Para esto incluí dos parámetros, "min" y "max" que como ya habrán intuido, se refiere al mínimo y máximo para el rango de números a filtrar. La variable "aux" y "aux2", fueron auxiliares en los que me apoyé para calcular el mayor y menor estudiante y también para hacer pruebas con el método burbuja, aunque luego abandoné esa idea porque al no haber un buen identificador, el ordenamiento hacía que se perdiera la secuencia relacionada con el iterador, haciendo que por ejemplo, el estudiante n° 1 pasara a ser el n° 4 y que los mensajes no concordaran luego. Eso podría haberlo modificado tomando más libertades con el uso de arreglos, pero esta vez no quise irme tan lejos para poder avanzar más en el curso.

El segundo auxiliar de tipo string, llamado "n_aux2" lo usé para filtrar las notas ingresadas, apoyándome en la función Is_Float que no fue de mi autoría, sino que encontré en un foro mientras estaba en la búsqueda de un filtro sencillo y funcional para números flotantes, el foro se llama StackOverFlow, gracias a "eferion" por responder a la duda que compartía con "Ali Rash", aunque él la tuvo hace 3 años.

Finalmente estuvieron las variables de tipo double "sumatoria" y "promedio", para el cumplir con los requerimientos que sus nombres describen, en relación a las notas ingresadas. Una vez se almacena el número de estudiantes, aparecen otro par de variables clave, dos arreglos de tipo float cuyo tamaño viene definido por ese número de estudiantes y que posteriormente serán cargados de las notas a través de un ciclo for que empieza en 0 y finaliza al cumplirse la condición de ser menor al número de estudiantes, de esa manera se evitan errores de concordancia con los índices de los arreglos, pues estos comienzan en 0.

Dentro del bucle for está un bucle do-while que se encarga de la validación, no solo de que el número sea flotante (sí !Isfloat(n_aux2) - sí el resultado de la función es falso, envía el mensaje de error), sino también de que el rango de las notas ingresada se mantenga entre 0 y 10. Posterior a esto está (aunque a modo de comentario), un for con la aplicación del método burbuja para ordenar. Seguido se encuentra un llamado a limpiar la pantalla, un salto de línea y un comentario que informa que se mostrara el grupo de estudiantes al que se les asignará el trabajo para aumentar un punto a su calificación (cuya nota sea menor o igual a 6).

Para cumplir con ese requerimiento usé un for que se encarga de "matar dos pájaros de un tiro", pues carga los datos de las notas a otro arreglo con la modificación de que aquellos con nota igual o menor a 6 se les aumenta un punto y también muestra qué estudiantes están en ese grupo (apoyándose del iterador). Posterior a esto se muestra el listado de notas de los alumnos y luego el listado de notas de los alumnos una vez se aplica la modificación (arreglo n1 sin modificar, arreglo n2 con las modificaciones).

For the function "notes_calculator()", we have multiple variables, starting with "n_student" to record the number of students once filtered with "n_aux", relying on the function "comprobator". This time I modified it a little to adapt it to the requirement of range in the number of students. For this I included two parameters, "min" and "max" that as you may have guessed, refers to the minimum and maximum for the range of numbers to filter. The variable "aux" and "aux2", were auxiliaries on which I relied to calculate the largest and smallest student and also to test with the bubble method, but then I abandoned that idea because in the absence of a good identifier, the ordering caused the sequence related to the iterator to be lost, causing, for example, student n° 1 to become n° 4 and the messages did not match later. I could have modified this by taking more liberties with the use of arrays, but this time I did not want to go that far in order to advance further in the course.

The second auxiliary of type string, called "n_aux2" I used it to filter the entered notes, relying on the function Is_Float that was not of my authorship, but that I found in a forum while I was in the search of a simple and functional filter for floating numbers, the forum is called StackOverFlow, thanks to "eferion" for answering the doubt that I shared with "Ali Rash", although he had it 3 years ago.

Finally there were the double type variables "summation" and "average", to fulfill the requirements that their names describe, in relation to the notes entered. Once the number of students is stored, another pair of key variables appear, two float type arrays whose size is defined by the number of students and that later will be loaded from the grades through a for loop that starts at 0 and ends when the condition of being less than the number of students is met, thus avoiding matching errors with the indexes of the arrays, because they start at 0.

Inside the for loop there is a do-while loop that is in charge of the validation, not only that the number is floating (yes !Isfloat(n_aux2) - if the result of the function is false, it sends the error message), but also that the range of the entered grades is maintained between 0 and 10. Then there is a call to clear the screen, a line break and a comment that informs that it will show the group of students to whom the work will be assigned to increase one point to their grade (whose grade is less than or equal to 6).

To fulfill this requirement I used a for that is in charge of "killing two birds with one stone", because it loads the data of the grades to another array with the modification that those with a grade equal or less than 6 are increased one point and also shows which students are in that group (supported by the iterator). After this, the list of students' grades is shown and then the list of students' grades once the modification is applied (array n1 without modification, array n2 with the modifications).

Programación c++.png

image.png

image.png

image.png

Programación c++.png

Posterior a esto se declaran dos variables de tipo int, menor = 10 y mayor = 0. Esto para que junto a los auxiliares, apoyen en el cálculo de qué estudiante cuenta con la menor y mayor nota promedio. Apliqué un método simple, aunque este no asegura que si se repiten dos estudiantes del peor o mejor promedio, se mencionen a ambos. Finalmente se calcula la sumaria y el promedio de notas con otro for y se muestran en pantalla los datos recopilados.

After this, two variables of type int are declared, minor = 10 and major = 0. This is so that together with the auxiliaries, they support the calculation of which student has the lowest and highest average grade. I applied a simple method, although this does not ensure that if two students of the worst or best average are repeated, both are mentioned. Finally, the sum and the grade point average are calculated with another for and the collected data are displayed on the screen.

Programación c++.png

image.png

image.png

image.png

From StackOverFlow, thanks to user eferion

Programación c++.png

ProyectoIII.gif

Created with VSDC Free Video Editor and Img2Go

Programación c++.png

¡Y bueno... Eso es todo por hoy! Ya vemos que la dificultad va escalando, eso me agrada bastante porque siento que crezco al enfrentarme a retos mayores. Te recomiendo aprovechar la oportunidad y unirte para crecer también y compartir de ese conocimiento a otros para que la cadena siga y siga, de modo que muchos tengan otra herramienta laboral genial o quizás solo un vistazo a otros oficios de nuestro mundo. Ya voy por el 50%, cada vez me acerco más a la meta, aunque mantener la disciplina ha sido un reto fuerte.

And well... That's all for today! We can already see that the difficulty is escalating, that pleases me a lot because I feel that I grow by facing bigger challenges. I recommend you to take advantage of the opportunity and join to grow too and share that knowledge to others so that the chain goes on and on, so that many have another great work tool or maybe just a glimpse of other trades in our world. I'm already at 50%, I'm getting closer and closer to the goal, although maintaining the discipline has been a strong challenge.

Programación c++.png


image.png
From AzulSchool, by: Angel Sánchez

Programación c++.png


Redes actualizada.gif


Puedes seguirme por acá si lo deseas:
You can follow me here if you want:

Cuenta secundaria
(Dibujos, edición y juegos) | Secondary account (Drawings, editing and games)



0
0
0.000
1 comments