Inicio > Programación > Programa de Tickets

Programa de Tickets

Código en C++

#include <cstdlib>
#include <iostream>

using namespace std;

int Venta(int sits[],int precio[], int x, int& venta)
{
int cantidad, total;
cout<<”\n Cantidad de taquillas: “;
cin>>cantidad;
if ( cantidad > sits[x])
{ cout<<”\n ** No hay suficientes taquillas **\n”;
return -1; }
sits[x] -= cantidad;
total = cantidad * precio[x];
venta += total;
return cantidad;
}

int main(int argc, char *argv[])
{
int sits[4];
int precio[4];
int e, ventas = 0;
int x;

sits[0] = 50; sits[1] = 100; sits[2] = 250; sits[3] = 65;
precio[0] = 1500; precio[1] = 900; precio[2] = 500; precio[3] = 100;

while(!0){

cout<<”\n Asientos Disponibles/Precios\n\n”;
cout<<” V.I.P.:\t”<< sits[0]<<” / $”<< precio[0]<< “\n”;
cout<<” Palco:\t”<< sits[1]<<” / $”<< precio[1]<< “\n”;
cout<<” Grada:\t”<< sits[2]<<” / $”<< precio[2]<< “\n”;
cout<<” Blicher:\t”<< sits[3]<<” / $”<< precio[3]<< “\n”;
cout<<”\n Total de Ventas:\t$”<< ventas<< “\n”;
cout<<”—————————–”;

cout << “\n\n Venta de Tickets\n\n\t1)V.I.P.\n\t2)Palco\n\t3)Grada\n\t4)Blicher\n\t0)Salir\n”;
cout << “>”;
cin >> x;

if(x == 0)
break;

switch(x){
case (1):
e=Venta(sits, precio, 0, ventas);
if (e==-1)
break;
cout<<”\n “<<e<<” taquillas V.I.P.\tTotal: $”<<e * precio[0]<< “\n”;
break;
case (2):
e=Venta(sits, precio, 1, ventas);
if (e==-1)
break;
cout<<”\n “<<e<<” taquillas Palco\tTotal: $”<<e * precio[1]<<”\n”;
break;
case (3):
e=Venta(sits, precio, 2, ventas);
if ( e==-1)
break;
cout<<”\n “<<e<<” taquillas Grada\tTotal: $”<<e * precio[2]<<”\n”;
break;
case (4):
e=Venta(sits, precio, 3, ventas);
if ( e == -1)
break;
cout<<”\n “<<e<<” taquillas Blicher\tTotal: $”<<e * precio[3]<<”\n”;
break;
default:
cout<<”\n\n Opcion No Valida\n”;
break; }
}
return EXIT_SUCCESS;
}

Advertisement
Categorías:Programación Etiquetas: , , ,
  1. Aún no hay comentarios.
  1. Aún no hay trackbacks

Deja un comentario

Fill in your details below or click an icon to log in:

Logo de WordPress.com

You are commenting using your WordPress.com account. Log Out / Cambiar )

Twitter picture

You are commenting using your Twitter account. Log Out / Cambiar )

Facebook photo

You are commenting using your Facebook account. Log Out / Cambiar )

Connecting to %s

Seguir

Get every new post delivered to your Inbox.