Data Formatting
Fixes upper and lower case, and converts between text and numbers.
- Level
- Intermediate
- Topic:
- Text
- Concepts:
- Input & output
- Text
Open in Codoritmo
Run, change and debug this example in your browser.
What you'll learn
Subcadena, Mayusculas, Minusculas and Concatenar work together to format a name. ConvertirANumero and ConvertirATexto turn data from one type into the other.
Code
Algoritmo FormatoDeDatos Definir nombre, apellido, nombreBonito, edadTexto Como Caracter Definir edad Como Entero Escribir "Nombre:" Leer nombre Escribir "Apellido:" Leer apellido Escribir "Edad:" Leer edadTexto // Primera letra en mayúscula y el resto en minúscula nombreBonito <- Concatenar(Mayusculas(Subcadena(nombre, 1, 1)), Minusculas(Subcadena(nombre, 2, Longitud(nombre)))) edad <- ConvertirANumero(edadTexto) Escribir "Ficha: ", nombreBonito, " ", Mayusculas(apellido) Escribir "Dentro de 10 años tendrá " + ConvertirATexto(edad + 10) + " años." Escribir "Letras en el nombre completo: ", Longitud(nombreBonito) + Longitud(apellido)FinAlgoritmoFlowchart
Each block in the flowchart matches one instruction in the code.
Sample run
This is what the program shows when it runs. The answers typed by the user are highlighted.
Nombre:User answer: lUCÍAApellido:User answer: gómezEdad:User answer: 15Ficha: Lucía GÓMEZDentro de 10 años tendrá 25 años.Letras en el nombre completo: 10
Challenge
Format the last name the same way: first letter uppercase, the rest lowercase.
Show hint
Repeat the nombreBonito line using apellido instead of nombre.
Related examples
Palindromes
Checks whether a phrase reads the same forwards and backwards.
IntermediateCount Vowels
Counts the vowels, spaces and other characters in a text.
IntermediateName Initials
Gets the initials of a full name.
Beginner