Documentation Index Fetch the complete documentation index at: https://mintlify.com/NormandoRamirezDelgado/6C-Febrero-2026/llms.txt
Use this file to discover all available pages before exploring further.
Exercise Overview
In this exercise, you’ll learn how to create a comprehensive grade management system that:
Captures student grades from user input
Calculates averages
Identifies grades above the average
Detects failing grades
Manages multiple lists (movies, colors, etc.)
Exercise 1: Grade Analysis System
Problem Statement
Create a program that:
Capture 5 grades
Ask the user to input 5 grades (decimal numbers)
Calculate average
Compute the average of all grades
Find grades above average
Display all grades that are greater than or equal to the average
Identify failing grades
Display all grades below 6.0 (failing grades)
Solution Components
Function 1: Capture Grades
import 'dart:io' ;
List < double > capturarCalificaciones ( List < double > calificaciones) {
for ( var i = 0 ; i < 5 ; i ++ ) {
print ( 'Introducir un Valor doble:' );
calificaciones. add ( double . parse (stdin. readLineSync () ! ));
}
return calificaciones;
}
This function uses double.parse() to convert string input to decimal numbers, allowing for grades like 8.5 or 9.75.
Function 2: Calculate Average
double calcularPromedio ( List < double > calificaciones) {
double suma = 0.0 ;
for ( var calificacion in calificaciones) {
suma += calificacion;
}
return suma / calificaciones.length;
}
Understanding the average calculation
The function:
Initializes a sum variable to 0.0
Iterates through all grades, adding each to the sum
Divides the sum by the total number of grades
Returns the result as a double
Function 3: Display Grades Above Average
void imprimirMayoresPromedio ( List < double > calificaciones, double promedio){
for ( var calificacion in calificaciones) {
if (calificacion >= promedio) {
print ( 'La calificacion $ calificacion es mayor o igual al Promedio' );
}
}
}
Function 4: Display Failing Grades
void imprimirReprobatorias ( List < double > calificaciones){
for ( var calificacion in calificaciones) {
if (calificacion < 6.0 ) {
print ( 'La calificacion $ calificacion es Reprobatoria' );
}
}
}
In this system, any grade below 6.0 is considered failing. Make sure to adjust this threshold based on your grading system.
Complete Program
import 'dart:io' ;
List < double > capturarCalificaciones ( List < double > calificaciones) {
for ( var i = 0 ; i < 5 ; i ++ ) {
print ( 'Introducir un Valor doble:' );
calificaciones. add ( double . parse (stdin. readLineSync () ! ));
}
return calificaciones;
}
double calcularPromedio ( List < double > calificaciones) {
double suma = 0.0 ;
for ( var calificacion in calificaciones) {
suma += calificacion;
}
return suma / calificaciones.length;
}
void imprimirMayoresPromedio ( List < double > calificaciones, double promedio){
for ( var calificacion in calificaciones) {
if (calificacion >= promedio) {
print ( 'La calificacion $ calificacion es mayor o igual al Promedio' );
}
}
}
void imprimirReprobatorias ( List < double > calificaciones){
for ( var calificacion in calificaciones) {
if (calificacion < 6.0 ) {
print ( 'La calificacion $ calificacion es Reprobatoria' );
}
}
}
void main () {
List < double > calificaciones = [];
capturarCalificaciones (calificaciones);
double promedio = calcularPromedio (calificaciones);
imprimirMayoresPromedio (calificaciones, promedio);
imprimirReprobatorias (calificaciones);
}
Exercise 2: Multiple List Management
Problem Statement
Create a program that manages two lists (movies and colors) and:
Load initial data
Collect 5 items for each list from the user
Add more data
Add one more item to each list
Display lists
Print all items in a numbered format
Show list sizes
Display the total count of items in each list
Solution Components
Reusable Function: Load List
import 'dart:io' ;
void cargarLista ( List < String > lista, String mensaje){
for ( var i = 0 ; i < 5 ; i ++ ) {
print ( 'Introducir tu $ mensaje :' );
lista. add (stdin. readLineSync () ! );
}
}
By accepting a mensaje parameter, this function can be reused for any type of list, making the code more maintainable.
Reusable Function: Add Data
List < String > agregarDatos ( List < String > lista, String mensaje) {
print ( ' \n Agregar $ mensaje :' );
lista. add (stdin. readLineSync () ! );
return lista;
}
Reusable Function: Print Lists
void imprimirListas ( List < String > lista, String mensaje) {
print ( ' \n Listado de $ mensaje :' );
for ( var i = 0 ; i < lista.length; i ++ ) {
print ( ' ${ i + 1 } - ${ lista [ i ]} ' );
}
}
The list is printed with 1-based numbering (i + 1) to make it more user-friendly, even though list indices start at 0.
Reusable Function: Display Size
void tamanioListas ( List < String > lista, String mensaje) {
print ( ' \n El tamaño de la lista de $ mensaje es: ${ lista . length } ' );
}
Complete Program
import 'dart:io' ;
void cargarLista ( List < String > lista, String mensaje){
for ( var i = 0 ; i < 5 ; i ++ ) {
print ( 'Introducir tu $ mensaje :' );
lista. add (stdin. readLineSync () ! );
}
}
List < String > agregarDatos ( List < String > lista, String mensaje) {
print ( ' \n Agregar $ mensaje :' );
lista. add (stdin. readLineSync () ! );
return lista;
}
void imprimirListas ( List < String > lista, String mensaje) {
print ( ' \n Listado de $ mensaje :' );
for ( var i = 0 ; i < lista.length; i ++ ) {
print ( ' ${ i + 1 } - ${ lista [ i ]} ' );
}
}
void tamanioListas ( List < String > lista, String mensaje) {
print ( ' \n El tamaño de la lista de $ mensaje es: ${ lista . length } ' );
}
void main () {
List < String > peliculas = [];
List < String > colores = [];
//Cargamos 5 datos en cada Lista
cargarLista (peliculas, 'Pelicula' );
print ( '' );
cargarLista (colores, 'Color' );
//Añadir 1 elemento más a cada lista
agregarDatos (peliculas, 'una Pelicula' );
agregarDatos (colores, 'un Color' );
//Imprimimos los elementos de lista de manera enumerada
imprimirListas (peliculas, 'Peliculas' );
imprimirListas (colores, 'Colores' );
//Imprimir el Tamaño de cada Lista
tamanioListas (peliculas, 'Peliculas' );
tamanioListas (colores, 'Colores' );
}
Key Concepts
List<double> Used for storing decimal numbers like grades
List<String> Used for storing text like movie names or colors
Reusable Functions Functions with parameters can work with different data
Data Validation Important to check for failing grades and other conditions
Practice Challenges
Challenge 1: Enhanced Statistics
Add functions to find:
Highest grade
Lowest grade
Number of passing grades
Percentage of students passing
Challenge 2: Grade Categories
Categorize grades into:
Excellent (9.0-10.0)
Good (8.0-8.9)
Satisfactory (7.0-7.9)
Passing (6.0-6.9)
Failing (below 6.0)
Challenge 3: Combined Lists
Modify the movie/color program to:
Allow the user to choose how many items to add initially
Add a search function to find specific items
Sort the lists alphabetically
Remove items by index
Best Practices
Separation of Concerns Each function should do one thing well
Meaningful Names Use descriptive function and variable names
Input Validation Always validate user input to prevent crashes
Code Reusability Write functions that can be used in different contexts