Problema de ciclos anidados y funciones

LLEVO ESTO

using namespace std;

void garb();
void lent();
void arve();
int gar[5], len[5], arv[5];

int main() {

int op;

do {
cout << "* * * MENU PRINCPIPAL * * *" << endl;
cout << "1. Ingresar granos" << endl;
cout << "2. Calcular costo por tipo de grano" << endl;
cout << "3. Calcular costo total" << endl;
cout << "4. Terminar" << endl;
cout << "Ingrese la opcion: ";
cin >> op;
switch (op)
{
case 1:
garb();
case 2:
lent();
case 3:
arve();
case 4:
break;
default:
break;
}
} while (op != 4);

system("pause");
}

void garb() {
int i = 0;
int op2;
system("cls");
cout << "1. Garbanzo" << endl;
cout << "2. Lenteja" << endl;
cout << "3. Arveja" << endl;
cout << "Ingrese la opcion: ";
cin >> op2;
switch (op2)
{
case 1:
cout << "Cuantas toneladas de garbanzo?" << endl;
cin >> gar[i];
i++;

default:
break;
}
}
void lent() {
int i = 0;
int op3;
system("cls");
cout << "1. Garbanzo" << endl;
cout << "2. Lenteja" << endl;
cout << "3. Arveja" << endl;
cout << "Ingrese la opcion: ";
cin >> op3;
switch (op3)
{
case 2:
cout << "Cuantas toneladas de lenteja?" << endl;
cin >> len[i];
i++;

default:
break;
}
}
void arve() {
int i = 0;
int op4;
system("cls");
cout << "1. Garbanzo" << endl;
cout << "2. Lenteja" << endl;
cout << "3. Arveja" << endl;
cout << "Ingrese la opcion: ";
cin >> op4;
switch (op4)
{
case 3:
cout << "Cuantas toneladas de arveja?" << endl;
cin >> arv[i];
i++;

default:
break;
}
}

Añade tu respuesta

Haz clic para o