Documentos de Académico
Documentos de Profesional
Documentos de Cultura
ÍNDICE
ÍNDICE.............................................................................................................................................................................. 1
1. EJERCICIO 1: RAÍCES POR MÉTODO DE NEWTON-RAPHSON ............................................................. 1
2. EJERCICIO 2: CONTROL DE LLAMADAS CON CLASES.......................................................................... 2
void main()
{
double cf[3];
double x;
int nIt, nMax=1000;
return val;
}
class Llamada
{
char telf[20];
double dur; //duracion en minutos
double precio; //por minuto
public:
Llamada(){}
void PedirDatos(){
cout << "Telefono:?"; cin >> telf;
cout << "Duracion:?"; cin >> dur;
cout << "Precio/Min:?"; cin >> precio;
}
void Ver()
{
cout <<setw(15) <<telf <<setw(10)<< dur <<setw(10) <<precio <<endl;
}
double GetCosto() { return precio*dur; }
};
void main()
{
int n=0,opc,i;
double tot=0;
Llamada lista[30];
while(1){
cout<<"\n**** Menu **** \n1.Agregar \n2.Ver Llamadas \n3.Salir
\n\tOpc:?";
cin >> opc;
switch (opc){
case 1:
lista[n].PedirDatos();
n++;
break;
case 2:
cout << setw(15) << "Telefono" << setw(10) << "Dur(min)";
cout << setw(10) << "Precio" << endl;
for ( i=0;i<n;i++) {
lista[i].Ver();
tot += lista[i].GetCosto();
}
cout << setw(15) << " " << setw(10) << "Total";
cout << setw(10) << tot << endl;
break;
case 3: return;
}
}
}