-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnuevo tp
99 lines (96 loc) · 2.5 KB
/
nuevo tp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#include<stdio.h>
#include<conio.h>
int funcion_opcion();
main()
{
int i,opcion,cant_vendida,cantidad_producto[6],cod_de_producto;
float precio_producto[6],p_prod_proveedor[6],venta,total;
char n_de_producto[6][15],n_de_proveedor[6][15],n_prod_proveedor[6][15];
for(i=1;i<=5;i++){
printf("Ingrese productos\n\n");
printf("Nombre de producto: ");
fflush(stdin);
gets(n_de_producto[i]);
printf("Precio de producto: ");
scanf("%f",&precio_producto[i]);
printf("Cantidad: ");
scanf("%i",&cantidad_producto[i]);
system("cls");
}
for(i=1;i<=5;i++){
printf("Ingrese Proveedores\n\n");
printf("Nombre de proveedor: ");
fflush(stdin);
gets(n_de_proveedor[i]);
printf("Nombre de producto: ");
fflush(stdin);
gets(n_prod_proveedor[i]);
printf("Precio de producto: ");
scanf("%f",&p_prod_proveedor[i]);
system("cls");
}
opcion=funcion_opcion();
while(opcion!=0){
switch(opcion){
case 1: //ventas
printf("Ingrese codigo de producto: ");
scanf("%i",&cod_de_producto);
printf("Ingrese cantidad: ");
scanf("%i",&cant_vendida);
for(i=1;i<=5;i++){
if(cod_de_producto==i){
if(cantidad_producto[i]>cant_vendida){
cantidad_producto[i]=cantidad_producto[i]-cant_vendida;
venta=cant_vendida*precio_producto[i];
}
else{
printf("Error!!! no hay suficientes %s",n_de_producto[i]);
}
}
}
getch();
system("cls");
break;
case 2: //proveedores
printf("Proveedores \n");
printf("Nombre \t\t Producto \t\t Precio\n");
for(i=1;i<=5;i++)
{
printf("%s\t\t %s \t\t %f\n",n_de_proveedor[i],n_prod_proveedor[i],p_prod_proveedor[i]);
}
getch();
system("cls");
break;
case 3: //stock
printf("Los productos \n");
printf("Nombre de producto \t Cantidad\n");
for(i=1;i<=5;i++)
{
printf("%s \t\t %i\n",n_de_producto[i],cantidad_producto[i]);
}
getch();
system("cls");
break;
case 4: //facturacion
printf("Lo total facturado hasta el momento es: %f",total);
break;
}//cierra switch
total=total+venta;
opcion=funcion_opcion();
}
}
int funcion_opcion(){
int opcion;
do{
printf("Ingrese la opcion deseada:\n");
printf("--------------------------------------\n");
printf("1-Ventas\n");
printf("2-Proveedores\n");
printf("3-Stock\n");
printf("4-Mostrar facturacion\n");
printf("0-Salir\n");
printf("Opcion: ");
scanf("%i",&opcion);
}while((opcion<0)||(opcion>4));
return opcion;
}