forked from ManuOSMx/Swift_Ubuntu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhola.swift
34 lines (27 loc) · 1007 Bytes
/
hola.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
//Creamos tipos de dato
let welcome = "Hola alumno:";
let students = ["Saul","Ximena","Sherani","Raul","Xaquenda","Abril","Javier"];
let teacher = "Manuel Ortiz";
//Imprimimos let en un print
print("\n¡Hola a todas y todos! \nSoy \(teacher) y esta es la primera linea de código para la clase de Swift en Linux.\n");
print("¿Cuantos alumnos quieres tener?");
let totalStudents = readLine()!;
let classRoom = Int(totalStudents)!;
var signStudents = 0;
//Contamos los elementos del array students
for _ in students {
signStudents += 1;
}
let difStudents = classRoom - signStudents;
if(difStudents < 0) {
print("Hay un excedente de alumnos en el grupo");
} else {
print("En este grupo hay disponibilidad total de \(classRoom) alumnos y en este momento hay inscritos: \(signStudents).");
print("Aun hay lugar para: \(difStudents) estudiantes.")
print("\nListado de alumnos inscritos:");
//recorremos el arreglo students
for student in students {
print(welcome, student);
}
}
print("")