Verificador de generación | C++
Muy buenos días, tardes o noches dependiendo de la hora en la que lees este humildes post. Estuve un tiempo sin publicar sobre programación por acá pero ya he vuelto con algo simple pero interesante... Boomers vs Millenials? Esas luchas son constantes en las redes sociales, por lo que si oíste esos términos seguramente tuviste la pregunta ¿A qué generación pertenezco?
En este programa respondo esa pregunta, a través del uso de un formato ya conocido por estos lados, pues parte del código usado en la calculadora de divisores, en la que conseguí un par de errores que corrijo por acá, estos errores están en el filtro de datos recibidos, es decir, si se ingresan letras en vez de números.
Saliendome un poco del tema, quería añadir que tengo algunas cosas que resolver con mi computadora principal, más que todo en cuanto al sistema. Cosa que me tomará tiempo por el respaldo pendiente a organizar, por ello programé en una laptop aparte, por eso la fuente se nota un poco distinta a lo habitual.
Good morning, afternoon or evening depending on the time you read this humble post. I haven't posted about programming here for a while but I'm back with something simple but interesting... Boomers vs Millenials? Those fights are constant in social networks, so if you heard those terms you probably had the question: Which generation do I belong to?
In this program I answer that question, through the use of a format already known in these parts, because part of the code used in the divisors calculator, in which I got a couple of errors that I correct here, these errors are in the filter of data received, ie, if you enter letters instead of numbers.
Going a little off topic, I wanted to add that I have some things to solve with my main computer, mostly in terms of the system. That will take me some time because of the pending backup to organize, so I programmed on a separate laptop, that's why the font looks a little different than usual.
Como bien mencionaba, el código parte de un formato que ya he usado antes, por ello la función inicial se basa en comprobar si los caracteres ingresados son números o no, esta se vuelve a usar en la función siguiente a modo de filtro. Uso la palabra "year" por el problema con la "ñ" por la base de idioma en el código para C++. Si los caracteres ingresados cumplen la condición, son convertidos a valores enteros para ser almacenados y retornados para su posterior uso.
En la siguiente función se pasa el año recibido por otro filtro, este compara dicho número con el rango de años que corresponde a cada generación, desde 1900 hasta 2026. La siguiente función corresponde a una pausa simple que uso varias veces para evitar los saltos bruscos entre mensajes mostrados en pantalla.
As I mentioned, the code starts from a format that I have used before, so the initial function is based on checking if the characters entered are numbers or not, this is used again in the following function as a filter. I use the word "year" because of the problem with the "ñ" because of the language base in the code for C++. If the characters entered meet the condition, they are converted to integer values to be stored and returned for later use.
The next function passes the received year through another filter, which compares that number with the range of years corresponding to each generation, from 1900 to 2026. The following function corresponds to a simple pause that I use several times to avoid abrupt jumps between messages displayed on the screen.
Para la siguiente función, usé un do-while combinado con un switch-case para crear un selector simple que funciona como menú cíclico para reutilizar el programa si el usuario lo desea, esto a través de la pregunta de si quiere continuar o salir (1) o (0).
En caso de continuar se usa el comprobador antes mencionado, una vez hecho esto se pasa a través de otro filtro que muestra si el año recibido es demasiado pequeño (La persona ya estaría muerta o la generación a buscar no estaría disponible en los rangos existentes en el código), o por el contrario muy grande (¿Un viajero del tiempo?). En caso de no querer continuar se envía un mensaje de despedida cordial.
En el main simplemente llamo a la función que combina todo lo antes mencionado, esto es el selector. Abajo añadí algunas capturas de ejecución.
For the following function, I used a do-while combined with a switch-case to create a simple selector that works as a cyclic menu to reuse the program if the user wishes, this through the question of whether to continue or exit (1) or (0).
In case of continuing, the above mentioned checker is used, once this is done, it is passed through another filter that shows if the year received is too small (The person would already be dead or the generation to look for would not be available in the existing ranges in the code), or on the contrary too large (A time traveler?). If you do not want to continue, a polite goodbye message is sent.
In the main I simply call the function that combines all the above mentioned, that is the selector. Below I added some screenshots of execution.
¡Y bueno... Eso es todo por hoy! Este sencillo programa me hizo sentir un poco viejo a pesar de que a penas entro a los 20's, ya varios niños me han dicho señor y eso me ha puesto a reflexionar jajaja. El tiempo pasa bastante rápido, esa moneda no se recupera, procuremos invertirla correctamente.
Si te interesa otro tutorial de programación acá te dejo los links a los que he realizado hasta ahora:
And well... That's all for today! This simple program made me feel a little old even though I'm just entering my 20's, several children have already told me sir and that has made me reflect hahaha. Time goes by pretty fast, that currency is not recovered, let's try to invest it correctly.
If you are interested in another programming tutorial here are the links to the ones I have done until now:
Título/Tittle | LINK | Título/Tittle | LINK |
---|---|---|---|
Calculador de datos para un triángulo rectángulo en C++ | 1 | Graficando números en consola (0-3) C++ | 16 |
Concecionario de autos, ejercicio en JAVA | 2 | Graficando números en consola II (4-6) C++ | 17 |
Calculador de edad básico C++ | 3 | Graficando números en consola III (7-9) C++ | 18 |
Inversor de números de tres cifras | 4 | Calculadora de ecuaciones cuadráticas C++ | 19 |
¿Cuántos números de 3 cifras existen cuya suma sea 10? - ¡Respondiendo a otro usuario! C++ | 5 | Dados digitales C++ | 20 |
Calculadora simple, cifra menos significativa y portada simple C++ | 6 | Fichas biográficas de próceres C++ | 21 |
¡Vistazo a BeatUDO! JAVA | 7 | Calculadora de divisores C++ | 22 |
Comprobar si un número de dos cifras es primo C++ | 8 | Calculadora de divisores II C++ | 23 |
Conversor de pulgadas a 7 unidades distintas C++ | 9 | Graficando letras en consola I (ABCDE) C++ | 24 |
Comprobar si un número es capicúa (Máx 5 cifras) C++ | 10 | Graficando letras en consola II (FGHIJ) C++ | 25 |
Comprobador de caracteres C++ | 11 | Graficando letras en consola III (KLMNO) C++ | 26 |
Calculadora de índice de masa corporal C++ | 12 | Graficando letras en consola V (UVWXYZ) C++ | 27 |
Calculadora de factoriales C++ | 13 | Generador de letras aleatorias C++ | 28 |
Conversor (Grados Celsius - Fahrenheit - Kelvin) C++ | 14 | X | X |
Calculadora de longitud, diametro y área de una circunferencia C++ | 15 | X | X |
https://twitter.com/gabrielrr018/status/1496997089867603969
The rewards earned on this comment will go directly to the person sharing the post on Twitter as long as they are registered with @poshtoken. Sign up at https://hiveposh.com.
Congratulations @gabrielr29! You received a personal badge!
You can view your badges on your board and compare yourself to others in the Ranking
Check out the last post from @hivebuzz:
Support the HiveBuzz project. Vote for our proposal!