Created
May 22, 2013 00:29
-
-
Save ahoulgrave/5624380 to your computer and use it in GitHub Desktop.
Sistema SUBE
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdlib> | |
#include <iostream> | |
using namespace std; | |
int main(int argc, char *argv[]) | |
{ | |
float costoEstacionGlew = 0.8; | |
float costoEstacionTemperley = 0.8; | |
float costoEstacionRemediosDeEscalada = 1.2; | |
float costoEstacionConstitucion = 2.4; | |
float saldo = 8.10; | |
float costo; | |
int opcionElegida; | |
printf("Bienvenido al sistema SUBE\n\n"); | |
do { | |
printf("Seleccione su destino:\n"); | |
printf("1. Glew:\n"); | |
printf("2. Temperley:\n"); | |
printf("3. Remedios de Escalada:\n"); | |
printf("4. Plaza Constitucion:\n"); | |
scanf("%d", &opcionElegida); | |
switch (opcionElegida) { | |
case 1: | |
costo = costoEstacionGlew; | |
break; | |
case 2: | |
costo = costoEstacionTemperley; | |
break; | |
case 3: | |
costo = costoEstacionRemediosDeEscalada; | |
break; | |
case 4: | |
costo = costoEstacionConstitucion; | |
break; | |
default: | |
printf("\nHas elegido una opcion invalida.\n\n"); | |
break; | |
} | |
} while ((opcionElegida < 1) || (opcionElegida > 4));// Esto es para que si elige una opcion que no existe, le vuelva a preguntar | |
if (saldo >= costo) { | |
saldo = saldo - costo; | |
printf("\nSe debitaron $%f de tu cuenta.\n",costo); | |
printf("\nTu saldo actual es %f.\n",saldo); | |
} else { | |
printf("\nNo tenes saldo suficiente en tu tarjeta SUBE."); | |
} | |
system("PAUSE"); | |
return EXIT_SUCCESS; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment