Verificador de generación | C++

avatar

Portada.jpg

Programación c++.png

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.

Programación c++.png

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.

1.png

2.png

3.png

4.png

Programación c++.png

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.

5.png

6.png

7.png

Programación c++.png

p1.png

p2.png

p3.png

p4.png

Programación c++.png

¡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/TittleLINKTítulo/TittleLINK
Calculador de datos para un triángulo rectángulo en C++1Graficando números en consola (0-3) C++16
Concecionario de autos, ejercicio en JAVA2Graficando números en consola II (4-6) C++17
Calculador de edad básico C++3Graficando números en consola III (7-9) C++18
Inversor de números de tres cifras4Calculadora de ecuaciones cuadráticas C++19
¿Cuántos números de 3 cifras existen cuya suma sea 10? - ¡Respondiendo a otro usuario! C++5Dados digitales C++20
Calculadora simple, cifra menos significativa y portada simple C++6Fichas biográficas de próceres C++21
¡Vistazo a BeatUDO! JAVA7Calculadora de divisores C++22
Comprobar si un número de dos cifras es primo C++8Calculadora de divisores II C++23
Conversor de pulgadas a 7 unidades distintas C++9Graficando letras en consola I (ABCDE) C++24
Comprobar si un número es capicúa (Máx 5 cifras) C++10Graficando letras en consola II (FGHIJ) C++25
Comprobador de caracteres C++11Graficando letras en consola III (KLMNO) C++26
Calculadora de índice de masa corporal C++12Graficando letras en consola V (UVWXYZ) C++27
Calculadora de factoriales C++13Generador de letras aleatorias C++28
Conversor (Grados Celsius - Fahrenheit - Kelvin) C++14XX
Calculadora de longitud, diametro y área de una circunferencia C++15XX

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
2 comments