
QUE GESTIONE LOS DATOS DE STOCK DE UNA TIENDA DE COMESTIBLES
Publicado por GABRIEL (1 intervención) el 19/04/2018 04:42:23
hola, no me corre mi programa no se que me falta
LA INFORMACIÓN A RECOGER SERÁ: NOMBRE DEL PRODUCTO, PRECIO, CANTIDAD EN STOCK. LA TIENDA DISPONE DE 10 PRODUCTOS DISTINTOS. EL PROGRAMA DEBE SER CAPAZ DE:
DAR DE ALTA UN PRODUCTO NUEVO.
BUSCAR UN PRODUCTO POR SU NOMBRE.
MODIFICAR EL STOCK Y PRECIO DE UN PRODUCTO DADO.
esto es lo que llevo. programo en c++, espero su pronta respuesta. gracias
LA INFORMACIÓN A RECOGER SERÁ: NOMBRE DEL PRODUCTO, PRECIO, CANTIDAD EN STOCK. LA TIENDA DISPONE DE 10 PRODUCTOS DISTINTOS. EL PROGRAMA DEBE SER CAPAZ DE:
DAR DE ALTA UN PRODUCTO NUEVO.
BUSCAR UN PRODUCTO POR SU NOMBRE.
MODIFICAR EL STOCK Y PRECIO DE UN PRODUCTO DADO.
esto es lo que llevo. programo en c++, espero su pronta respuesta. gracias
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
100
101
102
103
104
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
using namespace std;
struct producto {
char nombre[50];
float precio;
int cantidad;
};
int main(int argc, char *argv)
{
struct producto prod,productos[10];
int x,opcion=1;
for (x=0;x<10;x++)
{
strcpy(productos[x]nombre,"x")
productos[x].precio=0;
productos[x].cantidad=0;
}
while ((opcion==1 || opcion==2 || opcion==3) && (opcion!=4))
{
printf("1- Alta de producto\n");
printf("2- Buscar por nombre\n");
printf("3- Modificar stock y precio\n");
printf("4- Salir\n");
printf("Introduzca una opción: ");
scanf("%d",&opcion);
if (opcion==1)
{
printf("Introduzca un nombre: ");
gets(prod.nombre);
gets(prod.nombre);
printf("Introduzca un precio: ");
scanf("%f",&prod.precio);
printf("Introduzca un stock: ");
scanf("%d",&prod.cantidad);
for(x = 9; x >=0; x--)
{
if (x!=0)
{
strcpy(productos[x].nombre,productos[x-1].nombre);
productos[x].precio=productos[x-1].precio;
productos[x].cantidad=productos[x-1].cantidad;
}
else
{
strcpy(productos[x].nombre,prod.nombre);
productos[x].precio=prod.precio;
productos[x].cantidad=prod.cantidad;
}
}
printf("\nProducto creado. \n\n");
}
else if (opcion==2)
{
printf("Introduzca un nombre: ");
gets(prod.nombre);
gets(prod.nombre);
for(x = 0; x < 10;x++)
{
if (strcmp(productos[x].nombre,prod.nombre)==0)
{
printf("\nNombre: %s\n",productos[x].nombre);
printf("Precio: %f\n",productos[x].precio);
printf("Cantidad en Stock: %d\n",productos[x].cantidad);
}
}
printf("\n\n");
}
else if (opcion==3)
{
printf("Introduzca un nombre: ");
gets(prod.nombre);
gets(prod.nombre);
for(x = 0; x < 10;x++)
{
if (strcmp(productos[x].nombre,prod.nombre)==0)
{
printf("Introduzca un precio: ");
scanf("%f",&productos[x].precio);
printf("Introduzca un stock: ");
scanf("%d",&productos[x].cantidad);
printf("\nProducto modificado.");
}
}
printf("\n\n");
}
}
system("PAUSE");
return 0;
}
Valora esta pregunta


0