Consult Data from a Data Accessed C ++

0

Good afternoon, I have an exercise in which at first I ask for the Name and Certificate of a Person, I store them in a vector and run the program, with other calculations that I do. The case is that in the end develop a menu with several options, one of them is the list of all those people with their names and cedulas, the other option is that from a cedula ( data that I requested at the beginning), show me the data of that person .

The code where I ask for the data

for (i = 0; i < 2; i++)
{
    system("cls");
    total_mensual[i] = 0;
    sueldo_mensual[i] = 0;
    seguro[i] = 0;
    bono_mensual[i] = 0;
    sueldo_semana_total[i] = 0;
    cout<<"< = = = = = F A B R I C A de F O R R O S para V E H I C U L O S = = = = = >";
    cout<<"\n\nIngrese el Nombre del Trabajador: "<<i<<". ";
    cin>>nombre[i];
    cout<<"\nCedula del Trabajador: ";
    cin>>cedula[i];

The part of the menu where I want the data to be sent to me with the ID card

case 2:

        system("cls");
        cout<<"< = = = = = F A B R I C A de F O R R O S para V E H I C U L O S = = = = = >";
        cout<<"\n\nOpcion 2: Consulta de Datos por Cedula";
        cout<<"\n\nIngrese el Numero de Cedula: ";
        //Aqui ingreso la cedula, y luego deberia arrojarme los datos de la persona (nombre y cedula).
        break;
    
asked by Carlos Agustin Guanipa Alvarez 27.04.2017 в 19:14
source

1 answer

1

Only iterate inside your Array until you find a value of the card that corresponds to the value entered

cin>>cedulaingresada;
for (i = 0; i < 2; i++)
{
    if (cedulaingresada== cedula[i]) { 
           cout << total_mensual[i] << endl;
           cout << sueldo_mensual[i] << endl;
            //etcetera

    }

}
    
answered by 27.04.2017 / 19:58
source