
Ayuda no se como validar un nombre y clave
Publicado por full (1 intervención) el 15/11/2022 03:43:44
necesito ayuda, tengo que hacer que el usuario ingrese su nombre y edad pero que al ingresar en nombre solo acepte letras y en clave solo numeros y letras mayusculas (tienen que ser 5 caracteres numeros y letras mayusculas)
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include <iostream>
#include <conio.h>
#include <string>
using namespace std;
struct datos {
char Nombre[30];
char clave [5];
double precio = 0;
}persona[9];
void menu1();
int main() {
int opcion;
bool regresa=true;
do {
system("cls");
cout << "MENU PRINCIPAL" << endl;
cout << "---Ingrese una opcion---" << endl;
cout << "[1]. Registrar Persona" << endl;
cout << "[2]. Lista" << endl;
cout << "[0]. SALIR" << endl;
cin >> opcion;
switch (opcion) {
case 1:
system("cls");
for (int i = 0; i < 9; i++)
{
cin.ignore();
cout << " Ingrese el nombre "<< i+1 << endl;
cin.getline(persona[i].Nombre, 30);
cout << " Ingrese su edad "<<i+1 << endl;
cin.getline(persona[i].clave,5);
cin.ignore();
cout << " Ingrese el precio "<<i+1 << endl;
cin >> persona[i].precio;
cin.ignore();
system("cls");
}
system("PAUSE");
break;
case 2:
system("cls");
cout << "-Lista de Registro-" << endl;
for (int j = 0; j < 9; j++) {
cout <<"****************" << endl;
cout << "Registro numero " << j+1 << endl;
cout << "Nombre: " << persona[j].Nombre << endl;
cout << "clave: " << persona[j].clave << endl;
cout << "Precio: $" << persona[j].precio << endl;
}
system("PAUSE");
break;
case 0:
regresa = false;
break;
default:
cout << "Opcion incorrecta" << endl;
system("pause");
}
} while (regresa);
}
Valora esta pregunta


0