Advertisement
Guest User

ConcesionariaCoches2

a guest
Oct 17th, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.28 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<ctype.h>
  3. int LeeControlI(int,int);
  4. char LeeControlC (char,char,char,char);
  5. float LeeControlF(float);
  6. void CargaAutos(int[],char[],int[],float[],int);
  7. int ValidarC(int,int,int);
  8. main()
  9. {
  10. int cod[3],anio[3];
  11. char marca[3];
  12. float pre[3];
  13. int fp,dia,codi;
  14. CargaAutos(cod,marca,anio,pre,3);
  15. do{
  16. printf("\n Ingrese forma de pago: ");
  17. scanf("%d",&fp);
  18. }while(ValidarC(0,4,fp)==0);
  19. while(fp!=0)
  20. {
  21. printf("\n Ingrese dia: ");
  22. dia=LeeControlI(1,30);
  23. printf("\n Ingrese codigo del vehiculo: ");
  24. codi=LeeControlI(1500,9000);
  25. do{
  26. printf("\n Ingrese forma de pago: ");
  27. scanf("%d",&fp);
  28. }while(ValidarC(0,4,fp)==0);
  29. }
  30. }
  31. /////////////////////////////////////////
  32. int LeeControlI(int li, int ls)
  33. { int dato;
  34. do
  35. {
  36. scanf("%d",&dato);
  37. }while((dato<li)||(dato>ls));
  38. return(dato);
  39. }
  40. /////////////////////////////////////////
  41. char LeeControlC(char a, char b, char c, char d)
  42. { char dato;
  43. do
  44. {
  45. fflush(stdin);
  46. scanf("%c",&dato);
  47. dato=toupper(dato);
  48. }while((dato!=a)&&(dato!=b)&&(dato!=c)&&(dato!=d));
  49. return(dato);
  50. }
  51. /////////////////////////////////////////
  52. float LeeControlF(float x)
  53. { float dato;
  54. do
  55. {
  56. scanf("%f",&dato);
  57. }while(dato<x);
  58. return(dato);
  59. }
  60. ///////////////////////////////////////////
  61. void CargaAutos(int x[], char y[], int z[], float w[], int ce)
  62. {
  63. int i;
  64. for(i=0;i<ce;i++)
  65. {
  66. printf("\n Ingrese codigo: ");
  67. x[i]=LeeControlI(1500,9000);
  68. printf("\n Ingrese marca: ");
  69. y[i]=LeeControlC('F','R','C','A');
  70. printf("\n Ingrese anio: ");
  71. z[i]=LeeControlI(1900,2018);
  72. printf("\n Ingrese precio: ");
  73. w[i]=LeeControlF(0);
  74. }
  75. }
  76. /////////////////////////////////////////////////
  77. int ValidarC(int li, int ls, int dato)
  78. {
  79. switch(dato)
  80. {case 1: printf("Efectivo \n");
  81. break;
  82. case 2: printf("Tarjeta de credito \n");
  83. break;
  84. case 3: printf("Cheque\n");
  85. break;
  86. case 4: printf("Transferencia bancaria\n");
  87. break;
  88. default: printf("Operacion invalida\n");
  89. }
  90. return(dato);
  91. }
  92. /////////////////////////////////////////////////////
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement