function problem

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Jul 2008
Posts: 60
Reputation: gispe is an unknown quantity at this point 
Solved Threads: 0
gispe gispe is offline Offline
Junior Poster in Training

function problem

 
0
  #1
Jul 20th, 2009
Hi!
I've made this program, but not working First time I compiled it with MicrosoftC++ and gave me just 1 error, that corrected, then compiled it with DevC++ as teacher used it, and started giving me a lot of errors that some of them dont know how to correct them

Thanks in advanced


  1.  
  2. #include <cstdlib>
  3. #include <iostream>
  4.  
  5. using namespace std;
  6.  
  7. struct art
  8. {
  9. char name [50];
  10. char branch [50];
  11. float PrecioVenta;
  12. float PrecioCosto;
  13. int stock;
  14.  
  15. void load_art(float &price, char name, char branch, float &PrecioVenta, float &PrecioCosto, int &stock);
  16. void CambiarStock(int &stock);
  17. void ConsultarPrecioCosto(char name[], float PrecioCosto);
  18. void ConsultarPrecioVenta(char name[], float PrecioVenta);
  19. void mostrar(char name[], float price, char branch[], float PrecioVenta, float PrecioCosto, int stock);
  20. };
  21.  
  22.  
  23. struct StockGeneral
  24. {
  25. art datos[100];
  26.  
  27. char encontrado;
  28. int pos;
  29. char NombreBuscado[100];
  30.  
  31. StockGeneral();
  32. void BuscarStock(char NombreBuscado[], int &pos, char &encontrado);
  33. float CambiarPrecioVenta (float PrecioVenta);
  34. void CargarStockGeneral();
  35. void CompraArticulos();
  36. void MostrarStock();
  37. };
  38.  
  39.  
  40. struct client
  41. {
  42. char name[50];
  43. int id;
  44. char domicilio [100];
  45. float precio_acumulado;
  46.  
  47. void CargarDatos(int &id, char nombre[], char domicilio[], float &precio_acumulado);
  48. void MostrarDatos(int id, char nombre[], char domicilio[], float precio_acumulado);
  49. void ConsultarSaldo();
  50. void ActualizarSaldo(int id, float &precio_acumulado);
  51. };
  52.  
  53.  
  54. struct total_clients
  55. {
  56. client datos[100];
  57. int tope;
  58.  
  59. void CargarTotalClientes();
  60. void MostrarTotalClientes();
  61. void BuscarTotalClientes(char NombreBuscado[],int &pos, char &encontrado);
  62. };
  63.  
  64.  
  65.  
  66. struct venta
  67. {
  68. void CargarFactura(char name[], char branch[], int &stock, float &totalfactura);
  69. void MostrarFactura (char name[], char branch[], int &stock, float totalfactura);
  70. }
  71.  
  72.  
  73.  
  74.  
  75. //----------------------------------
  76. //
  77. // ART - FUNCIONES
  78. //
  79. //----------------------------------
  80.  
  81. void art::load_art(float &price, char name, char branch, float &PrecioVenta, float &PrecioCosto, int &stock)
  82. {
  83. art article;
  84.  
  85. cout << " ------------------------------------- \n\n";
  86. cout << " CARGA DATOS DEL ARTICULO: \n";
  87. cout << " ------------------------------------- \n\n";
  88.  
  89. cout<< " Nombre: ";
  90. cin.getline(article.name, 50);
  91.  
  92. cout << " Marca: ";
  93. cin.getline(article.branch, 50);
  94.  
  95. cout << " Precio Venta: ";
  96. cin >> article.PrecioVenta;
  97.  
  98. cout << " Precio Costo: ";
  99. cin >> article.PrecioCosto;
  100.  
  101. cout << " Stock: ";
  102. cin >> article.stock;
  103. }
  104.  
  105.  
  106. void art::CambiarStock (int &stock)
  107. {
  108. art article;
  109.  
  110. cout << " Ingrese el nombre del articulo: ";
  111. cin.getline(article.name, 50);
  112.  
  113. cout << " Ingresar nuevo stock: ";
  114. cin >> article.stock;
  115. }
  116.  
  117.  
  118. void art::ConsultarPrecioCosto (char name[], float PrecioCosto)
  119. {
  120. art article;
  121.  
  122. cout << " Ingrese el nombre del articulo: ";
  123. cin.getline(article.name, 50);
  124.  
  125. cout << " El precio es: " << article.PrecioCosto;
  126. }
  127.  
  128.  
  129. void art::ConsultarPrecioVenta (char name[], float PrecioVenta)
  130. {
  131. art article;
  132.  
  133. cout << " Ingrese el nombre del articulo: ";
  134. cin.getline(article.name, 50);
  135.  
  136. cout << " El precio es: " << article.PrecioVenta;
  137. }
  138.  
  139.  
  140. void art::mostrar(char name[], float price, char branch[], float PrecioVenta, float PrecioCosto, int stock)
  141. {
  142. art article;
  143.  
  144. cout << " -------------------------------------------------------------- \n";
  145. cout << " -------------------------- ARTICULO --------------------------";
  146. cout << " -- Nombre: " << article.name << "\n";
  147. cout << " -- Marca: " << article.branch << "\n";
  148. cout << " -- Precio de Venta: " << article.PrecioVenta << "\n"; //EXPECTED ; BEFORE "ARTICLE"
  149. cout << " -- Precio de Costo: " << article.PrecioCosto << "\n";
  150. cout << " -- Stock: " << article.stock << "\n"; // EPECTED ; BEFORE "ARTICLE"
  151. cout << " -------------------------------------------------------------- \n";
  152. }
  153.  
  154.  
  155.  
  156. //----------------------------------
  157. //
  158. // STOCK - FUNCIONES
  159. //
  160. //----------------------------------
  161.  
  162. StockGeneral::StockGeneral()
  163. {
  164. int tope[100];
  165.  
  166.  
  167. for (int i =0; i <100; i++)
  168. tope[i]=0;
  169. }
  170.  
  171.  
  172.  
  173. void StockGeneral::CargarStockGeneral()
  174. {
  175. art article;
  176. char rta;
  177. int tope;
  178.  
  179. while (tope<100)
  180. {
  181. do {
  182. datos[pos].load_art(price, name[], branch, PrecioVenta, PrecioCosto, stock);
  183. tope++;
  184. cout << " Cargar otro? S/N?";
  185. cin >> rta;
  186. cin.ignore();
  187. } while(rta != 'n' && rta!='N');
  188.  
  189. system("CLS");
  190. }
  191. }
  192.  
  193.  
  194. void StockGeneral::BuscarStock(char NombreBuscado[],int &pos, char &encontrado)
  195. {
  196. art article;
  197. encontrado=0;
  198. pos=0;
  199. int tope=100;
  200. int i=0;
  201.  
  202. while ((pos < tope) && (strcmp(NombreBuscado, article.name)!=0))
  203. {
  204. pos++;
  205.  
  206. if (pos<tope)
  207. encontrado=1;
  208. else
  209. pos=1;
  210. }
  211. }
  212.  
  213.  
  214. float StockGeneral::CambiarPrecioVenta (float PrecioVenta)
  215. {
  216. char encontrado;
  217. art article;
  218.  
  219. cout << " Ingrese el nombre del articulo: ";
  220. cin.getline(article.name, 50);
  221.  
  222. StockGeneral.BuscarStock(NombreBuscado[], pos, encontrado);
  223.  
  224. if (encontrado==0)
  225. {
  226. cout << " Ingresar precio de costo del articulo: ";
  227. cin >> PrecioVenta;
  228. }
  229. else if (encontrado == 1)
  230. cout << " No se puede cambiar el precio. \n El articulo ingresado no existe. \n\n";
  231.  
  232. return PrecioVenta;
  233. }
  234.  
  235.  
  236. void StockGeneral::CompraArticulos()
  237. {
  238. char NombreBuscado[100], encontrado;
  239. int stockaux, pos;
  240.  
  241. cout << " Escribir nombre de articulo a cambiar stock: ";
  242. cin.getline(NombreBuscado, 100);
  243.  
  244. StockGeneral.BuscarStock(NombreBuscado[], pos, encontrado);
  245.  
  246. if (encontrado==0)
  247. {
  248. cout << " Ingresar stock del articulo a comprar: ";
  249. cin >> stockaux;
  250.  
  251. datos[pos].stock += stockaux;
  252.  
  253. cout << " Se actualizo el stock.-";
  254. }
  255. else if (encontrado == 1)
  256. cout << " No se puede cambiar el precio. \n El articulo ingresado no existe. \n\n";
  257.  
  258. }
  259.  
  260.  
  261. void StockGeneral::MostrarStock()
  262. {
  263. art articulo;
  264.  
  265. cout << " ------------------------------------------------------------------- \n";
  266. cout << " -------------------------- STOCK GENERAL -------------------------- \n";
  267. cout << " ------------------------------------------------------------------- \n";
  268.  
  269. for (int i=0; i <100; i++)
  270. articulo.mostrar(name[], branch[], PrecioVenta, PrecioCosto, stock);
  271.  
  272. cout << " ------------------------------------------------------------------- \n";
  273. cout << " ------------------------------------------------------------------- \n";
  274. cout << " ------------------------------------------------------------------- \n";
  275. }
  276.  
  277.  
  278.  
  279.  
  280. //----------------------------------
  281. //
  282. // CLIENTE - FUNCIONES
  283. //
  284. //----------------------------------
  285.  
  286.  
  287. void client::CargarDatos(int &id, char nombre[], char domicilio[], float &precio_acumulado)
  288. {
  289. client cliente;
  290.  
  291. cout << " INGRESO DE DATOS DEL CLIENTE: \n";
  292. cout << " ------------------------------------- \n\n";
  293.  
  294. cout << " Codigo: ";
  295. cin >> cliente.id;
  296.  
  297. cout << " Nombre: ";
  298. cin.getline (cliente.name,50);
  299.  
  300. cout << " Domicilio: ";
  301. cin.getline (cliente.domicilio,100);
  302.  
  303. cout << " Saldo Acumulado: ";
  304. cin >> cliente.precio_acumulado;
  305. }
  306.  
  307.  
  308. void client::MostrarDatos(int id, char nombre[], char domicilio[], float precio_acumulado)
  309. {
  310. client cliente;
  311.  
  312. cout << " -+-+-+- DATOS DEL CLIENTE -+-+-+- \n";
  313. cout << " ---------------------------------------------------- \n\n\n";
  314. cout << " --- ID:" << cliente.id << " \n";
  315. cout << " --- Nombre: " << cliente.name << " \n";
  316. cout << " --- Domicilio: " << cliente.domicilio << "\n";
  317. cout << " --- Saldo: " << cliente.precio_acumulado << "\n";
  318. cout << " ---------------------------------------------------- \n\n\n";
  319. }
  320.  
  321.  
  322. void client::ConsultarSaldo()
  323. {
  324. client cliente;
  325.  
  326. cout << " Ingrese ID del cliente: ";
  327. cin >> cliente.id;
  328.  
  329. cout << " El saldo es " << cliente.precio_acumulado << " \n";
  330. }
  331.  
  332.  
  333.  
  334. void client::ActualizarSaldo(int id, float &precio_acumulado)
  335. {
  336. client cliente;
  337. float nuevosaldo;
  338.  
  339. cout << " Ingresar ID del cliente: ";
  340. cin >> cliente.id;
  341.  
  342. cout << " Ingrese nuevo Saldo: ";
  343. cin >> nuevosaldo;
  344.  
  345. cliente.precio_acumulado = nuevosaldo;
  346. }
  347.  
  348.  
  349.  
  350.  
  351.  
  352.  
  353.  
  354.  
  355.  
  356.  
  357.  
  358. //----------------------------------
  359. // TOTAL DE CLIENTES
  360. //
  361. // FUNCIONES
  362. //----------------------------------
  363.  
  364.  
  365. void total_clients::CargarTotalClientes()
  366. {
  367. char rta;
  368.  
  369. while (tope<100)
  370. {
  371. do {
  372. datos[tope].CargarDatos();
  373. tope++;
  374. cout << " Cargar otro? S/N?";
  375. cin >> rta;
  376. cin.ignore();
  377. } while(rta != 'n' && rta!='N');
  378.  
  379. system("CLS");
  380. }
  381. }
  382.  
  383.  
  384. void total_clients::MostrarTotalClientes()
  385. {
  386. client cliente;
  387. int id;
  388. char name [50], domicilio [100];
  389. float precio_acumulado;
  390.  
  391. cout << " DETALLE DE TODOS LOS CLIENTES: \n";
  392. cout << " ------------------------------------------------- \n\n";
  393. cliente.MostrarDatos(id, name, domicilio, precio_acumulado);
  394. cout << " ------------------------------------------------- \n\n";
  395. }
  396.  
  397.  
  398. void total_clients::BuscarTotalClientes(char NombreBuscado[],int &pos, char &encontrado)
  399. {
  400. art article;
  401. encontrado=0;
  402. pos=0;
  403. int tope=100;
  404.  
  405. while ((pos <tope) && (strcmp(NombreBuscado, article[pos].name)!=0))
  406. {
  407. pos++;
  408.  
  409. if (pos<tope)
  410. encontrado=true;
  411. else
  412. pos=1;
  413. }
  414. }
  415.  
  416.  
  417.  
  418.  
  419.  
  420.  
  421.  
  422. //----------------------------------
  423. // FACTURAS
  424. //
  425. // FUNCIONES
  426. //----------------------------------
  427.  
  428.  
  429. void venta::CargarFactura(char name[], char branch[], int &stock, float totalfactura)
  430. {
  431. art articulo;
  432. int stockfactura;
  433. float totalfactura;
  434.  
  435. cout << " Ingresar nombre de articulo a vender: ";
  436. cin.getline(articulo.name, 50);
  437.  
  438. StockGeneral.BuscarStock(NombreBuscado, pos, encontrado);
  439.  
  440. if (encontrado == 1)
  441. {
  442. cout << " Ingresar marca: ";
  443. cin.getline(articulo.branch,50);
  444.  
  445. cout << " Ingresar stock: ";
  446. cin >> stockfactura;
  447.  
  448. while (stockfactura > articulo.stock)
  449. {
  450. cout << " No se puede vender esa cantidad. \n Ingresar stock correcto: ";
  451. cin >> stockfactura;
  452. }
  453. }
  454. articulo.stock = articulo.stock - stockfactura;
  455.  
  456. totalfactura= stockfactura*articulo.PrecioVenta;
  457.  
  458. cout << " Ingresar nombre de cliente: ";
  459. cin.getline (client.name, 50);
  460.  
  461. total_clients.BuscarCliente(NombreBuscado, pos, encontrado);
  462.  
  463. if (encontrado == 1)
  464. {
  465. client.precio_acumulado = client.precio_acumulado - totalfactura;
  466.  
  467. if (client.precio_acumulado < 0)
  468. cout << " No se puede realizar esta venta.";
  469. }
  470. else if (encontrado ==0)
  471. cout << " El cliente ingresado no existe. \n";
  472.  
  473. }
  474.  
  475.  
  476.  
  477. void venta::MostrarFactura(char name[], char branch[], int &stock, float totalfactura)
  478. {
  479. cout << " ---------------------------------------------------- ";
  480. cout << " -- Articulo: " << art.name << "\n";
  481. cout << " -- Marca: " << art.branch << "\n";
  482. cout << " -- Stock vendido: " << art.stock << "\n\n";
  483. cout << " -- Cliente: " << client.name << "\n";
  484. cout << " -- Saldo actual del cliente: " << client.precio_acumulado << "\n\n\n";
  485. cout << " ---------- TOTAL FACTURA: -- $" << totalfactura << "\n";
  486. }
  487.  
  488.  
  489.  
  490.  
  491.  
  492.  
  493.  
  494.  
  495.  
  496.  
  497.  
  498.  
  499.  
  500.  
  501.  
  502.  
  503.  
  504.  
  505.  
  506.  
  507.  
  508.  
  509.  
  510.  
  511. //----------------------------------
  512. //
  513. // MAIN
  514. //
  515. //----------------------------------
  516.  
  517. int main()
  518. {
  519. art articulos;
  520. StockGeneral StockTotal;
  521. client clientes;
  522. total_clients todoslosclientes;
  523. venta factura;
  524.  
  525.  
  526. float totalfactura;
  527. int stock;
  528.  
  529. char choice;
  530.  
  531. cout << " ------------------------------------------- \n";
  532. cout << " -------------- ELEGIR ACCION -------------- \n";
  533. cout << " ------------------------------------------- \n\n";
  534.  
  535. cout << " -1- Cargar articulos. \n"; // LLAMA A CARGAR DEL STOCKGENERAL
  536. cout << " -2- Consultar Precio de Costo. \n";
  537. cout << " -3- Consultar Precio de Venta. \n";
  538. cout << " -4- Cambiar Stock. \n";
  539. cout << " -5- Mostrar articulos. \n\n"; // MOSTRAR DEL STOCKGENERAL
  540. cout << " -6- Buscar un articulo. \n";
  541. cout << " -7- Comprar articulos. \n";
  542. cout << " -8- Mostrar StockGeneral. \n\n";
  543. cout << " -9- Cargar datos del cliente. \n";
  544. cout << " -a- Consultar Saldo. \n";
  545. cout << " -b- Actualizar saldo. \n";
  546. cout << " -c- Buscar Cliente. \n";
  547. cout << " -d- Mostrar clientes. \n\n";
  548. cout << " -h- Cargar datos para factura. \n";
  549. cout << " -i- Mostrar factura. \n\n";
  550. cout << " -0- Salir. \n\n";
  551. cout << " Elegiste: ";
  552. cin >> choice;
  553.  
  554. cout << " ------------------------------------------- \n\n";
  555. cout << " ------------------------------------------- \n\n";
  556. cout << " ------------------------------------------- \n\n";
  557.  
  558. switch (choice)
  559. {
  560. case '1':
  561. StockTotal.CargarStockGeneral();
  562. break;
  563.  
  564. case '2':
  565. articulo.consultarprecosto();
  566. break;
  567.  
  568. case '3':
  569. articulo.consultarprevta();
  570. break;
  571.  
  572. case '4':
  573. articulo.cambiarcosto();
  574. break;
  575.  
  576. case '5':
  577. StockTotal.MostrarStock();
  578. break;
  579.  
  580. case '6':
  581. StockTotal.BuscarStock(NombreBuscado[], pos, encontrado);
  582. break;
  583.  
  584. case '7':
  585. StockTotal.CompraArticulos();
  586. break;
  587.  
  588. case '8':
  589. StockTotal.MostrarStock();
  590. break;
  591.  
  592. case '9':
  593. todoslosclientes.CargarTotalClientes();
  594. break;
  595.  
  596. case 'a': case 'A':
  597. clientes.ConsultarSaldo();
  598. break;
  599.  
  600. case 'b':case 'B':
  601. clientes.ActualizarSaldo();
  602. break;
  603.  
  604. case 'c': case 'C':
  605. todoslosclientes.BuscarTotalClientes();
  606. break;
  607.  
  608. case 'd': case 'D':
  609. todoslosclientes.MostrarTotalClientes();
  610. break;
  611.  
  612. case 'h': case 'H':
  613. factura.CargarFactura(name[], branch[], stock, totalfactura);
  614. break;
  615.  
  616. case 'i': case 'I':
  617. factura.MostrarFactura();
  618. break;
  619.  
  620. case'0':
  621. cout << " ---Fin del programa--- \n";
  622. }
  623.  
  624. system("PAUSE");
  625. return EXIT_SUCCESS;
  626. }
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,445
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1475
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: function problem

 
0
  #2
Jul 20th, 2009
>>First time I compiled it with MicrosoftC++ and gave me just 1 error, that corrected
You should have tried to compile it again with that compiler. I used VC++ 2008 Express and the code you posted had billions of error messages.


There are indeed several errors.

1) struct art -- you should make that a class, not a struct. Yes they are nearly the same thing but its customary to call it a class when it has methods. Same with struct venta.

2) you forgot the semicolon at the end of struct venta

Lots of other problems that you need to fix.
Last edited by Ancient Dragon; Jul 20th, 2009 at 10:41 am.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 60
Reputation: gispe is an unknown quantity at this point 
Solved Threads: 0
gispe gispe is offline Offline
Junior Poster in Training

Re: function problem

 
0
  #3
Jul 21st, 2009
Hi!
I corrected the errors it was giving me, but now, when i try to create a new client makes a loop after the client's address and doesnt go out
and the other thing is that when try to create new client, doesnt let me not to create another client.
and this is more like a logical question: in the function "void BuscarStock(char NombreBuscado[], int &pos, char &encontrado);" and the ones look like it, doesnt really look for what they should look for.
dont knowwhat im doing wrong with it

thanks in advanced


  1.  
  2. #include <cstdlib>
  3. #include <iostream>
  4.  
  5. using namespace std;
  6.  
  7. struct art
  8. {
  9. char name [50];
  10. char branch [50];
  11. float PrecioVenta;
  12. float PrecioCosto;
  13. int stock;
  14.  
  15. void load_art(float &price, char name[], char branch[], float &PrecioVenta, float &PrecioCosto, int &stock);
  16. void CambiarStock(int &stock);
  17. void ConsultarPrecioCosto(char name[], float PrecioCosto);
  18. void ConsultarPrecioVenta(char name[], float PrecioVenta);
  19. void mostrar(char name[], float price, char branch[], float PrecioVenta, float PrecioCosto, int stock);
  20. };
  21.  
  22.  
  23. struct StockGeneral
  24. {
  25. art datos[100];
  26.  
  27. char encontrado;
  28. int pos;
  29. char NombreBuscado[100];
  30.  
  31. StockGeneral();
  32. void BuscarStock(char NombreBuscado[], int &pos, char &encontrado);
  33. float CambiarPrecioVenta (float PrecioVenta);
  34. void CargarStockGeneral();
  35. void CompraArticulos();
  36. void MostrarStock();
  37. };
  38.  
  39.  
  40. struct client
  41. {
  42. char name[50];
  43. int id;
  44. char domicilio [100];
  45. float precio_acumulado;
  46.  
  47. void CargarDatos(int &id, char nombre[], char domicilio[], float &precio_acumulado);
  48. void MostrarDatos(int id, char nombre[], char domicilio[], float precio_acumulado);
  49. void ConsultarSaldo();
  50. void ActualizarSaldo(int id, float &precio_acumulado);
  51. };
  52.  
  53.  
  54. struct total_clients
  55. {
  56. client datos[100];
  57. int tope;
  58.  
  59. void CargarTotalClientes();
  60. void MostrarTotalClientes();
  61. void BuscarTotalClientes(char NombreBuscado[],int &pos, char &encontrado);
  62. };
  63.  
  64.  
  65.  
  66. struct venta
  67. {
  68. void venta::CargarFactura(char name[], char branch[], int &stock, float totalfactura);
  69. void MostrarFactura (char name[], char branch[], int &stock, float totalfactura);
  70. };
  71.  
  72.  
  73.  
  74.  
  75. //----------------------------------
  76. //
  77. // ART - FUNCIONES
  78. //
  79. //----------------------------------
  80.  
  81. void art::load_art(float &price, char name[], char branch[], float &PrecioVenta, float &PrecioCosto, int &stock)
  82. {
  83. art article;
  84.  
  85. cout << " ------------------------------------- \n\n";
  86. cout << " CARGA DATOS DEL ARTICULO: \n";
  87. cout << " ------------------------------------- \n\n";
  88.  
  89. cout<< " Nombre: ";
  90. cin.getline(article.name, 50);
  91.  
  92. cout << " Marca: ";
  93. cin.getline(article.branch, 50);
  94.  
  95. cout << " Precio Venta: ";
  96. cin >> article.PrecioVenta;
  97.  
  98. cout << " Precio Costo: ";
  99. cin >> article.PrecioCosto;
  100.  
  101. cout << " Stock: ";
  102. cin >> article.stock;
  103. }
  104.  
  105.  
  106. void art::CambiarStock (int &stock)
  107. {
  108. art article;
  109.  
  110. cout << " Ingrese el nombre del articulo: ";
  111. cin.getline(article.name, 50);
  112.  
  113. cout << " Ingresar nuevo stock: ";
  114. cin >> article.stock;
  115. }
  116.  
  117.  
  118. void art::ConsultarPrecioCosto (char name[], float PrecioCosto)
  119. {
  120. art article;
  121.  
  122. cout << " Ingrese el nombre del articulo: ";
  123. cin.getline(article.name, 50);
  124.  
  125. cout << " El precio es: " << article.PrecioCosto;
  126. }
  127.  
  128.  
  129. void art::ConsultarPrecioVenta (char name[], float PrecioVenta)
  130. {
  131. art article;
  132.  
  133. cout << " Ingrese el nombre del articulo: ";
  134. cin.getline(article.name, 50);
  135.  
  136. cout << " El precio es: " << article.PrecioVenta;
  137. }
  138.  
  139.  
  140. void art::mostrar(char name[], float price, char branch[], float PrecioVenta, float PrecioCosto, int stock)
  141. {
  142. art article;
  143.  
  144. cout << " -------------------------------------------------------------- \n";
  145. cout << " -------------------------- ARTICULO --------------------------";
  146. cout << " -- Nombre: " << article.name << "\n";
  147. cout << " -- Marca: " << article.branch << "\n";
  148. cout << " -- Precio de Venta: " << article.PrecioVenta << "\n"; //EXPECTED ; BEFORE "ARTICLE"
  149. cout << " -- Precio de Costo: " << article.PrecioCosto << "\n";
  150. cout << " -- Stock: " << article.stock << "\n"; // EPECTED ; BEFORE "ARTICLE"
  151. cout << " -------------------------------------------------------------- \n";
  152. }
  153.  
  154.  
  155.  
  156. //----------------------------------
  157. //
  158. // STOCK - FUNCIONES
  159. //
  160. //----------------------------------
  161.  
  162. StockGeneral::StockGeneral()
  163. {
  164. int tope[100];
  165.  
  166.  
  167. for (int i =0; i <100; i++)
  168. tope[i]=0;
  169. }
  170.  
  171.  
  172.  
  173. void StockGeneral::CargarStockGeneral()
  174. {
  175. art article;
  176. char rta;
  177. int tope;
  178.  
  179. float price, PrecioVenta, PrecioCosto;
  180. char name[50], branch[50];
  181. int stock;
  182.  
  183. while (tope<100)
  184. {
  185. do {
  186. datos[pos].load_art(price, name, branch, PrecioVenta, PrecioCosto, stock);
  187. tope++;
  188. cout << " Cargar otro? S/N?";
  189. cin >> rta;
  190. cin.ignore();
  191. } while(rta != 'n' && rta!='N');
  192.  
  193. system("CLS");
  194. }
  195. }
  196.  
  197.  
  198. void StockGeneral::BuscarStock(char NombreBuscado[],int &pos, char &encontrado)
  199. {
  200. art article;
  201. encontrado=0;
  202. pos=0;
  203. int tope=100;
  204. int i=0;
  205.  
  206. while ((pos < tope) && (strcmp(NombreBuscado, article.name)!=0))
  207. {
  208. pos++;
  209.  
  210. if (pos<tope)
  211. encontrado=1;
  212. else
  213. pos=1;
  214. }
  215. }
  216.  
  217.  
  218. float StockGeneral::CambiarPrecioVenta (float PrecioVenta)
  219. {
  220. char encontrado;
  221. art article;
  222. StockGeneral stockdetotales;
  223.  
  224. cout << " Ingrese el nombre del articulo: ";
  225. cin.getline(article.name, 50);
  226.  
  227. stockdetotales.BuscarStock(NombreBuscado, pos, encontrado);
  228.  
  229. if (encontrado==0)
  230. {
  231. cout << " Ingresar precio de costo del articulo: ";
  232. cin >> article.PrecioVenta;
  233. }
  234. else if (encontrado == 1)
  235. cout << " No se puede cambiar el precio. \n El articulo ingresado no existe. \n\n";
  236.  
  237. return PrecioVenta;
  238. }
  239.  
  240.  
  241. void StockGeneral::CompraArticulos()
  242. {
  243. char NombreBuscado[100], encontrado;
  244. int stockaux, pos;
  245. StockGeneral stockdetotales;
  246.  
  247. cout << " Escribir nombre de articulo a cambiar stock: ";
  248. cin.getline(NombreBuscado, 100);
  249.  
  250. stockdetotales.BuscarStock(NombreBuscado, pos, encontrado);
  251.  
  252. if (encontrado==0)
  253. {
  254. cout << " Ingresar stock del articulo a comprar: ";
  255. cin >> stockaux;
  256.  
  257. datos[pos].stock += stockaux;
  258.  
  259. cout << " Se actualizo el stock.-";
  260. }
  261. else if (encontrado == 1)
  262. cout << " No se puede cambiar el precio. \n El articulo ingresado no existe. \n\n";
  263.  
  264. }
  265.  
  266.  
  267. void StockGeneral::MostrarStock()
  268. {
  269. art articulo;
  270.  
  271. char name[50], branch[50];
  272. float PrecioVenta, PrecioCosto, price;
  273. int stock;
  274.  
  275. cout << " ------------------------------------------------------------------- \n";
  276. cout << " -------------------------- STOCK GENERAL -------------------------- \n";
  277. cout << " ------------------------------------------------------------------- \n";
  278.  
  279. for (int i=0; i <100; i++)
  280. articulo.mostrar(name, price, branch, PrecioVenta, PrecioCosto, stock);
  281.  
  282. cout << " ------------------------------------------------------------------- \n";
  283. cout << " ------------------------------------------------------------------- \n";
  284. cout << " ------------------------------------------------------------------- \n";
  285. }
  286.  
  287.  
  288.  
  289.  
  290. //----------------------------------
  291. //
  292. // CLIENTE - FUNCIONES
  293. //
  294. //----------------------------------
  295.  
  296.  
  297. void client::CargarDatos(int &id, char nombre[], char domicilio[], float &precio_acumulado)
  298. {
  299. client cliente;
  300.  
  301. cout << " INGRESO DE DATOS DEL CLIENTE: \n";
  302. cout << " ------------------------------------- \n\n";
  303.  
  304. cout << " Codigo: ";
  305. cin >> cliente.id;
  306.  
  307. cout << " Nombre: ";
  308. cin.getline (cliente.name,50);
  309.  
  310. cin.ignore();
  311.  
  312. cout << " Domicilio: ";
  313. cin.getline (cliente.domicilio,100);
  314.  
  315. cin.ignore();
  316.  
  317. cout << " Saldo Acumulado: ";
  318. cin >> cliente.precio_acumulado;
  319. }
  320.  
  321.  
  322. void client::MostrarDatos(int id, char nombre[], char domicilio[], float precio_acumulado)
  323. {
  324. client cliente;
  325.  
  326. cout << " -+-+-+- DATOS DEL CLIENTE -+-+-+- \n";
  327. cout << " ---------------------------------------------------- \n\n\n";
  328. cout << " --- ID:" << cliente.id << " \n";
  329. cout << " --- Nombre: " << cliente.name << " \n";
  330. cout << " --- Domicilio: " << cliente.domicilio << "\n";
  331. cout << " --- Saldo: " << cliente.precio_acumulado << "\n";
  332. cout << " ---------------------------------------------------- \n\n\n";
  333. }
  334.  
  335.  
  336. void client::ConsultarSaldo()
  337. {
  338. client cliente;
  339.  
  340. cout << " Ingrese ID del cliente: ";
  341. cin >> cliente.id;
  342.  
  343. cout << " El saldo es " << cliente.precio_acumulado << " \n";
  344. }
  345.  
  346.  
  347.  
  348. void client::ActualizarSaldo(int id, float &precio_acumulado)
  349. {
  350. client cliente;
  351. float nuevosaldo;
  352.  
  353. cout << " Ingresar ID del cliente: ";
  354. cin >> cliente.id;
  355.  
  356. cout << " Ingrese nuevo Saldo: ";
  357. cin >> nuevosaldo;
  358.  
  359. cliente.precio_acumulado = nuevosaldo;
  360. }
  361.  
  362.  
  363.  
  364.  
  365.  
  366.  
  367.  
  368.  
  369.  
  370.  
  371.  
  372. //----------------------------------
  373. // TOTAL DE CLIENTES
  374. //
  375. // FUNCIONES
  376. //----------------------------------
  377.  
  378.  
  379. void total_clients::CargarTotalClientes()
  380. {
  381. char rta;
  382.  
  383. int id;
  384. char nombre[50], domicilio[100];
  385. float precio_acumulado;
  386.  
  387.  
  388. while (tope<100)
  389. {
  390. datos[tope].CargarDatos(id, nombre, domicilio, precio_acumulado);
  391.  
  392. cout << " Cargar otro - S/N?";
  393. cin >> rta;
  394.  
  395. while ((rta != 'n') && (rta!='N'))
  396. {
  397. datos[tope].CargarDatos(id, nombre, domicilio, precio_acumulado);
  398. tope++;
  399. cout << " Cargar otro - S/N?";
  400. cin >> rta;
  401. cin.ignore();
  402. }
  403.  
  404. system("CLS");
  405. }
  406. }
  407.  
  408.  
  409. void total_clients::MostrarTotalClientes()
  410. {
  411. client cliente;
  412. int id;
  413. char name [50], domicilio [100];
  414. float precio_acumulado;
  415.  
  416. cout << " DETALLE DE TODOS LOS CLIENTES: \n";
  417. cout << " ------------------------------------------------- \n\n";
  418. cliente.MostrarDatos(id, name, domicilio, precio_acumulado);
  419. cout << " ------------------------------------------------- \n\n";
  420. }
  421.  
  422.  
  423. void total_clients::BuscarTotalClientes(char NombreBuscado[],int &pos, char &encontrado)
  424. {
  425. art article;
  426. encontrado=0;
  427. pos=0;
  428. int tope=100;
  429.  
  430. while ((pos <tope) && (strcmp(NombreBuscado, article.name)!=0))
  431. {
  432. pos++;
  433.  
  434. if (pos<tope)
  435. encontrado=true;
  436. else
  437. pos=1;
  438. }
  439. }
  440.  
  441.  
  442.  
  443.  
  444.  
  445.  
  446.  
  447. //----------------------------------
  448. // FACTURAS
  449. //
  450. // FUNCIONES
  451. //----------------------------------
  452.  
  453.  
  454. void venta::CargarFactura(char name[], char branch[], int &stock, float totalfactura)
  455. {
  456. art articulo;
  457. int stockfactura;
  458.  
  459. StockGeneral stockdetotales;
  460. client cliente;
  461. total_clients totaldeclientes;
  462.  
  463. char NombreBuscado[50], encontrado;
  464. int pos;
  465.  
  466. cout << " Ingresar nombre de articulo a vender: ";
  467. cin.getline(articulo.name, 50);
  468.  
  469. stockdetotales.BuscarStock(NombreBuscado, pos, encontrado);
  470.  
  471. if (encontrado == 1)
  472. {
  473. cout << " Ingresar marca: ";
  474. cin.getline(articulo.branch,50);
  475.  
  476. cout << " Ingresar stock: ";
  477. cin >> stockfactura;
  478.  
  479. while (stockfactura > articulo.stock)
  480. {
  481. cout << " No se puede vender esa cantidad. \n Ingresar stock correcto: ";
  482. cin >> stockfactura;
  483. }
  484. }
  485. articulo.stock = articulo.stock - stockfactura;
  486.  
  487. totalfactura= stockfactura*(articulo.PrecioVenta);
  488.  
  489. cout << " Ingresar nombre de cliente: ";
  490. cin.getline (cliente.name, 50);
  491.  
  492. totaldeclientes.BuscarTotalClientes(NombreBuscado, pos, encontrado);
  493.  
  494. if (encontrado == 1)
  495. {
  496. cliente.precio_acumulado = cliente.precio_acumulado - totalfactura;
  497.  
  498. if (cliente.precio_acumulado < 0)
  499. cout << " No se puede realizar esta venta.";
  500. }
  501. else if (encontrado ==0)
  502. cout << " El cliente ingresado no existe. \n";
  503.  
  504. }
  505.  
  506.  
  507.  
  508. void venta::MostrarFactura(char name[], char branch[], int &stock, float totalfactura)
  509. {
  510. art article;
  511. client cliente;
  512.  
  513. cout << " ---------------------------------------------------- ";
  514. cout << " -- Articulo: " << article.name << "\n";
  515. cout << " -- Marca: " << article.branch << "\n";
  516. cout << " -- Stock vendido: " << article.stock << "\n\n";
  517. cout << " -- Cliente: " << cliente.name << "\n";
  518. cout << " -- Saldo actual del cliente: " << cliente.precio_acumulado << "\n\n\n";
  519. cout << " ---------- TOTAL FACTURA: -- $" << totalfactura << "\n";
  520. cout << " ---------------------------------------------------- ";
  521. }
  522.  
  523.  
  524.  
  525.  
  526.  
  527.  
  528.  
  529.  
  530.  
  531.  
  532.  
  533.  
  534.  
  535.  
  536.  
  537.  
  538.  
  539.  
  540.  
  541.  
  542.  
  543.  
  544.  
  545.  
  546. //----------------------------------
  547. //
  548. // MAIN
  549. //
  550. //----------------------------------
  551.  
  552. int main()
  553. {
  554. art articulos;
  555. StockGeneral StockTotal;
  556. client clientes;
  557. total_clients todoslosclientes;
  558. venta factura;
  559.  
  560. float precio_acumulado;
  561. float PrecioCosto, PrecioVenta;
  562. char NombreBuscado[50], branch[50], name[50], encontrado;
  563. int id, pos;
  564.  
  565. float totalfactura;
  566. int stock;
  567.  
  568. char choice;
  569.  
  570. cout << " ------------------------------------------- \n";
  571. cout << " -------------- ELEGIR ACCION -------------- \n";
  572. cout << " ------------------------------------------- \n\n";
  573.  
  574. cout << " -1- Cargar articulos. \n";
  575. cout << " -2- Consultar Precio de Costo. \n";
  576. cout << " -3- Consultar Precio de Venta. \n";
  577. cout << " -4- Cambiar Stock. \n";
  578. cout << " -5- Mostrar articulos. \n\n";
  579. cout << " -6- Buscar un articulo. \n";
  580. cout << " -7- Comprar articulos. \n";
  581. cout << " -8- Mostrar StockGeneral. \n\n";
  582. cout << " -9- Cargar datos del cliente. \n";
  583. cout << " -a- Consultar Saldo. \n";
  584. cout << " -b- Actualizar saldo. \n";
  585. cout << " -c- Buscar Cliente. \n";
  586. cout << " -d- Mostrar clientes. \n\n";
  587. cout << " -h- Cargar datos para factura. \n";
  588. cout << " -i- Mostrar factura. \n\n";
  589. cout << " -0- Salir. \n\n";
  590. cout << " Elegiste: ";
  591. cin >> choice;
  592.  
  593. cout << " ------------------------------------------- \n\n";
  594. cout << " ------------------------------------------- \n\n";
  595. cout << " ------------------------------------------- \n\n";
  596.  
  597. system("CLS");
  598.  
  599. switch (choice)
  600. {
  601. case '1':
  602. StockTotal.CargarStockGeneral();
  603. break;
  604.  
  605. case '2':
  606. articulos.ConsultarPrecioCosto(name, PrecioCosto);
  607. break;
  608.  
  609. case '3':
  610. articulos.ConsultarPrecioVenta(name, PrecioVenta);
  611. break;
  612.  
  613. case '4':
  614. articulos.CambiarStock(stock);
  615. break;
  616.  
  617. case '5':
  618. StockTotal.MostrarStock();
  619. break;
  620.  
  621. case '6':
  622. StockTotal.BuscarStock(NombreBuscado, pos, encontrado);
  623. break;
  624.  
  625. case '7':
  626. StockTotal.CompraArticulos();
  627. break;
  628.  
  629. case '8':
  630. StockTotal.MostrarStock();
  631. break;
  632.  
  633. case '9':
  634. todoslosclientes.CargarTotalClientes();
  635. break;
  636.  
  637. case 'a': case 'A':
  638. clientes.ConsultarSaldo();
  639. break;
  640.  
  641. case 'b':case 'B':
  642. clientes.ActualizarSaldo(id, precio_acumulado);
  643. break;
  644.  
  645. case 'c': case 'C':
  646. todoslosclientes.BuscarTotalClientes(NombreBuscado, pos, encontrado);
  647. break;
  648.  
  649. case 'd': case 'D':
  650. todoslosclientes.MostrarTotalClientes();
  651. break;
  652.  
  653. case 'h': case 'H':
  654. factura.CargarFactura(name, branch, stock, totalfactura);
  655. break;
  656.  
  657. case 'i': case 'I':
  658. factura.MostrarFactura(name, branch, stock, totalfactura);
  659. break;
  660.  
  661. case'0':
  662. cout << " ---Fin del programa--- \n";
  663. }
  664.  
  665. system("PAUSE");
  666. return EXIT_SUCCESS;
  667. }
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,445
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1475
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: function problem

 
0
  #4
Jul 21st, 2009
That program still has warning about uninitialized variables being used. Fix them because the program will have erratic behavior the way it is.
Last edited by Ancient Dragon; Jul 21st, 2009 at 1:42 pm.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 60
Reputation: gispe is an unknown quantity at this point 
Solved Threads: 0
gispe gispe is offline Offline
Junior Poster in Training

Re: function problem

 
0
  #5
Jul 21st, 2009
I just fixed those warnings (didnt appear with dev). Now, thing is: when try to create an article, program wont let me stop creating new stuff, justs keeps on going. dont really know what im doing wrong.

thanks in advanced

  1.  
  2. void StockGeneral::CargarStockGeneral()
  3. {
  4. char rta;
  5. int tope =0;
  6.  
  7. float price, PrecioVenta, PrecioCosto;
  8. char name[50], branch[50];
  9. int stock;
  10.  
  11. while (tope<100)
  12. {
  13. do {
  14. datos[pos].load_art(price, name, branch, PrecioVenta, PrecioCosto, stock);
  15. tope++;
  16. cout << " Cargar otro? S/N?";
  17. cin >> rta;
  18. cin.ignore();
  19. } while(rta != 'n' && rta!='N');
  20.  
  21. system("CLS");
  22. }
  23. }
Attached Files
File Type: cpp TpFinalProg1.cpp (18.1 KB, 1 views)
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 18
Reputation: 23.12.2012 is an unknown quantity at this point 
Solved Threads: 1
23.12.2012's Avatar
23.12.2012 23.12.2012 is offline Offline
Newbie Poster

Re: function problem

 
0
  #6
Jul 21st, 2009
Try using Code::Blocks as your IDE, because I'm sure this uses MinGW, which is the Windows port of the GNU C++ Compiler, which is probably the best C++ compiler. Or... you could try installing Ubuntu and run the original compiler. This way, I'm positive you'll get all the errors that are there in your program.

After doing this myself with your program, I see that you're using stdafx.h , which, as far as I'm concerned, is a Windows-specific header file. The compiler didn't even bother showing the other errors. I'd recommend you to rethink the program using Standard C++, and completely rewrite it.
Last edited by 23.12.2012; Jul 21st, 2009 at 8:56 pm.
I strongly recommend using The GNU C++ Compiler as your C++ compiler. It comes with every UNIX/Linux machine, including Mac OS X. If you're a Windows user, have a look over MinGW
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 60
Reputation: gispe is an unknown quantity at this point 
Solved Threads: 0
gispe gispe is offline Offline
Junior Poster in Training

Re: function problem

 
0
  #7
Jul 21st, 2009
I mean, the program as it is in the att. i added was working, didnt gave me any errors. My question was more bout the code i pasted.
Thanks-
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 29
Reputation: losh177 is an unknown quantity at this point 
Solved Threads: 0
losh177 losh177 is offline Offline
Light Poster

Re: function problem

 
0
  #8
Jul 22nd, 2009
To answer your question on why the program is not stopping, it is because you have an infinite loop on line 19 where you are using the AND operator

  1. while(rta != 'n' && rta!='N')
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC