PROGRAMA PARA UNA TERMINAL DE TRASPORTE TERRESTRE.
Enviado por harold_araque • 27 de Enero de 2016 • Apuntes • 1.055 Palabras (5 Páginas) • 303 Visitas
//PROGRAMA PARA UNA TERMINAL DE TRASPORTE TERRESTRE.
PARTE .H
#include <iostream>
#include <string>
#include <fstream>
#include <iomanip>
using namespace std;
struct MyStruct
{
string destino;
string duracion;
string economico;
string corriente;
string lujo;
int costo;
}registro,viaje[30];
void agregar()
{
cout << "Escriba el Destino: ";
cin >> registro.destino;
cout << "Duracion del Viaje";
cin >> registro.duracion;
cout << "Descripcion del Bus Economico ";
cin >> registro.economico;
cout << "Descripcion del Bus Corriente ";
cin >> registro.corriente;
cout << "Descripcion del Bus Lujo ";
cin >> registro.lujo;
cout << "Valor del Viaje";
cin >> registro.costo;
ofstream guardar("MyStruct.txt", ios::app);
guardar << registro.destino<< " " << registro.duracion << " "
<< registro.economico<< " " << registro.corriente << " "
<< registro.lujo<< " " << registro.costo << endl;
guardar.close();
}
void carga(int &j)
{
j = 0;
ifstream lee("MyStruct.txt");
while (lee >> viaje[j].destino >> viaje[j].duracion >> viaje[j].economico
>> viaje[j].corriente >> viaje[j].lujo >> viaje[j].costo)
j++;
lee.close();
}
int buscar(int &j)
{
cout << "Digite el Destino" << endl;
cin >> registro.destino;
carga(j);
for (int x = 0; x < j; x++)
if (registro.destino == viaje[x].destino)
{
cout << setw(14) << viaje[x].destino << setw(14) << viaje[x].duracion;
cout << setw(14) << viaje[x].economico << setw(14) << viaje[x].corriente;
cout << setw(14) << viaje[x].lujo << setw(14) << viaje[x].costo << setw(14) << endl;
return j;
}
return -1;
}
void mostrar()
{
ifstream lee("MyStruct.txt");
cout << setw(14) << "Destino" << setw(14) << "Duracion Viaje" << setw(14) << "Bus Economico" << setw(14)
<< "Bus Corriente" << setw(14) << "Bus Lujo" << setw(14) << "Costo" << setw(14) << endl;
while (lee >> registro.destino >> registro.duracion >> registro.economico
>> registro.corriente >> registro.lujo >> registro.costo)
cout << setw(14) << registro.destino << setw(14) << registro.duracion << setw(14) << registro.economico
<< setw(14) << registro.corriente << setw(14) << registro.lujo << setw(14) << registro.costo << setw(14)<< endl;
}
void eliminar(int &j)
{
int d;
d = buscar(j);
if (d <= 0)
{
viaje[d].destino = " ";
viaje[d].duracion = " ";
viaje[d].economico = " ";
viaje[d].corriente = " ";
viaje[d].lujo = " ";
actualizar(j);
}
else
...