Home > Programacion I > Programa de tickets

Programa de tickets

/* Este codigo se encuentra en lenguaje C++ */

#include <cstdlib>
#include <iostream>

using namespace std;

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

int main(int argc, char *argv[])
{
int sits[4];
int price[4];
int e, balance = 0;

sits[0] = 20; sits[1] = 40; sits[2] = 100; sits[3] = 80;
price[0] = 500; price[1] = 300; price[2] = 150; price[3] = 50;

char x;

while(!0){

cout << “\n Asientos Disponibles/Precios\n\n”;
cout << ”   V.I.P.:\t” << sits[0] << “/$” << price[0] << “\n”;
cout << ”   Palco:\t” << sits[1] << “/$” << price[1] << “\n”;
cout << ”   Grada:\t” << sits[2] << “/$” << price[2] << “\n”;
cout << ”   Blicher:\t” << sits[3] << “/$” << price[3] << “\n”;
cout << “\n    Balance:\t$” << balance << “\n”;

cout << “\n   —–> Menu <—–\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’ || x == ‘s’)
break;

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

Categories: Programacion I
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

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

WordPress.com Logo

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

Twitter picture

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

Facebook photo

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

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: