Advertisement
Guest User

Untitled

a guest
Mar 13th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. #include <iostream>
  2. #include <conio.h>
  3. #include <string.h>
  4.  
  5. using namespace std;
  6.  
  7. const int neg = 5;
  8.  
  9. struct negocios {
  10. char nombre[20];
  11. int precio, produccion;
  12. bool creada;
  13. }negocios[5];
  14.  
  15. void crear() {
  16. bool cr = true;
  17. int id;
  18. do {
  19. system ("cls");
  20. cout << "Selecciona la id de un negocio\n";
  21. cin >> id;
  22. if (id > neg || id < 0) {
  23. cout << "Negocio no valido!\n";
  24. system ("pause");
  25. }
  26. else if (negocios[id].creada == true) {
  27. cout << "Este negocio ya existe!\n";
  28. system ("pause");
  29. }
  30. else {
  31. cout << "Selecciona un nombre para tu negocio: ";
  32. cin.getline(negocios[id].nombre,20,'\n');
  33. cout << "Selecciona un precio para tu negocio: ";
  34. cin >> negocios[id].precio; cout << "\n";
  35. cout << "Selecciona la produccion por hora de tu negocio: ";
  36. cin >> negocios[id].produccion; cout << "\n";
  37. cout << "Negocio creado!";
  38. negocios[id].creada = true;
  39. cr = false;
  40. }
  41. } while (cr == true);
  42.  
  43. system ("pause");
  44. }
  45.  
  46. void leer() {
  47. system ("cls");
  48. cout << "Leyendo datos...\n";
  49. for (int i = 0; i < neg; i++) {
  50. cout << "Los datos del negocio son:\n";
  51. cout << negocios[i].nombre << '\n';
  52. }
  53. }
  54.  
  55. void menu() {
  56. char opc;
  57.  
  58. system ("cls");
  59. cout << "-------------------------------------------\n";
  60. cout << "Bienvenido al administrador de propiedades.\n";
  61. cout << "-------------------------------------------\n";
  62. cout << "Que desea hacer?\n";
  63. cout << "1. Crear una propiedad\n2. Eliminar una propiedad\n3. Lista de propiedades\n4. Salir\n";
  64. cin >> opc;
  65.  
  66. switch (opc) {
  67. case '1':
  68. crear();
  69. break;
  70. case '2':
  71. break;
  72. case '3':
  73. break;
  74. case '4':
  75. break;
  76. default:
  77. break;
  78. }
  79. }
  80.  
  81. int main() {
  82.  
  83. menu();
  84.  
  85. return 0;
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement