#include <iostream>
#include <cctype> // toupper
using namespace std;
void menu();
int cargos(int base);
const int A = 1200000;
const int B = 950000;
int main() {
char opcion;
do {
menu();
cin >> opcion;
switch (opcion) {
case '1':
cout << "\nPlan A: " <<
"\n Coste base: " << A;
cout << "\n\n Cote Total: " << cargos(A) + A <<
endl;
break;
case '2':
cout << "\nPlan B: " <<
"\n Coste base: " << B;
cout << "\n\n Cote Total: " << cargos(B) + B <<
endl;
break;
case '3':
cout << "\nFIN DEL PROGRAMA" << endl;
break;
default:
cout << "\nOPCION NO VALIDA" << endl;
break;
}
if (opcion == '1' || opcion == '2') {
cout << "\n\nGracias por comprar en nuestros seguros.";
cin.get(); cin.get();
system("cls");
}
} while (opcion != '3');
cout << endl;
return 0;
}
void menu() {
cout << "\n SEGUROS CARONI" <<
"\n========================" <<
"\n1.- Plan A ....... [ 1 ]" <<
"\n2.- Plan B ....... [ 2 ]" <<
"\n3.- Terminar ..... [ 3 ]" <<
"\n========================" <<
"\nOPCION (1 - 3): ";
}
int cargos(int base) {
char opcion;
int beber, lentes, enfermo, edad;
beber = lentes = enfermo = edad = 0.0f;
do {
cout << "\n\nEs bebedor (S/n)? ";
cin >> opcion;
} while (opcion != 's' && opcion != 'S' && opcion != 'n' && opcion != 'N');
opcion = toupper(opcion);
if (opcion == 'S') {
beber = base * 0.10;
}
do {
cout << "Utiliza lentes (S/n)? ";
cin >> opcion;
} while (opcion != 's' && opcion != 'S' && opcion != 'n' && opcion != 'N');
opcion = toupper(opcion);
if (opcion == 'S') {
lentes = base * 0.05;
}
do {
cout << "Padece alguna enfrmedad (S/n)? ";
cin >> opcion;
} while (opcion != 's' && opcion != 'S' && opcion != 'n' && opcion != 'N');
opcion = toupper(opcion);
if (opcion == 'S') {
enfermo = base * 0.05;
}
do {
cout << "Tiene mas de 40 anios (S/n)? ";
cin >> opcion;
} while (opcion != 's' && opcion != 'S' && opcion != 'n' && opcion != 'N');
opcion = toupper(opcion);
if (opcion == 'S') {
beber = base * 0.20;
}
if (beber > 0) cout << "\n Recargo por bebedor: " << beber;
if (lentes > 0) cout << "\n Recargo por usar lentes: " << lentes;
if (enfermo > 0) cout << "\n Recargo por enfermedad: " << enfermo;
if (edad > 0) cout << "\n Recargo por mayor de 40 anyos: " << edad;
return beber + lentes + enfermo + edad;
}