Posted By

anja2pet on 11/20/10


Tagged


Versions (?)

glavni program


 / Published in: C++
 

  1. #include <iostream>
  2. #include <cstdlib>
  3.  
  4. using namespace std;
  5.  
  6. struct tBanka {
  7. char ime_prezime[30];
  8. int godina;
  9. int saldo;
  10. int trans;
  11. };
  12.  
  13. typedef tBanka elementtype;
  14.  
  15. #include "red_polje.h"
  16. //#include "red_pokazivac.h"
  17.  
  18. void cunos(char *znakovni_niz){
  19. cin.getline(znakovni_niz, 30);
  20. if (cin.gcount()==1)
  21. cin.getline(znakovni_niz, 30);
  22. };
  23.  
  24.  
  25. // UNOS PODATAKA **********************************************************************************************
  26.  
  27. void unos(qu *red){
  28.  
  29. char novi_unos;
  30. elementtype temp;
  31.  
  32. cout << "============================================== \n";
  33. cout << " *** Unos podataka *** \n";
  34. cout << "============================================== \n\n";
  35.  
  36. do {
  37. cout << "Ime i prezime: "; cunos(temp.ime_prezime);
  38. cout << "\nGodina rodjenja: "; cin >> temp.godina;
  39. cout << "\nStanje racuna: "; cin >> temp.saldo;
  40.  
  41. do{
  42. cout << "\nVrsta transakcije: \n\n 1. Uplata/isplata";
  43. cout << "\n 2. Placanje racuna\n 3. Zahtjev za kredit ";
  44. cout << "\n\nIzbor: "; cin >> temp.trans;
  45. if (temp.trans > 0 && temp.trans < 4){break;}
  46. else
  47. cout << "\n Pogresan odabir ! Molimo ponovite unos ! \n\n";
  48. }while(true);
  49.  
  50. cout << "---------------------------------------------- \n\n\n";
  51.  
  52. EnQueueQ(temp,red);
  53.  
  54. cout << " Zelite novi unos: (d/n)? "; cin >> novi_unos; cout << "\n\n";
  55. }while(novi_unos == 'd');
  56. cout << " Zahvaljujemo na unosu. \n\n\n\n ";
  57. };
  58.  
  59.  
  60. // ISPIS REDA *************************************************************************************************
  61.  
  62. void ispis(qu *red){
  63.  
  64. elementtype temp;
  65. qu *red_temp = new qu;
  66. InitQ(red_temp);
  67.  
  68. if(IsEmptyQ(red)){
  69. cout << "\n\n\n\n Molimo unesite podatke o klijentima ! \n";
  70. cout << "\n\n (Odaberite mogucnost 1 u glavnom izborniku.) \n\n\n\n\n";
  71. }
  72.  
  73. while(!IsEmptyQ(red)){
  74. EnQueueQ(FrontQ(red),red_temp);
  75. temp = FrontQ(red);
  76. DeQueueQ(red);
  77.  
  78. cout << "\nIme i prezime: " << temp.ime_prezime;
  79. cout << "\nGodina rodjenja: " << temp.godina;
  80. cout << "\nStanje racuna: " <<temp.saldo << " kn ";
  81. cout << "\nVrsta transakcije: " ;
  82. if(temp.trans==1)cout << "Uplata/isplata \n";
  83. else if(temp.trans==2)cout << "Placanje racuna \n";
  84. else cout << "Zahtjev za kredit \n";
  85. cout << "----------------------------------------------\n\n";
  86. };
  87.  
  88. while(!IsEmptyQ(red_temp)){
  89. EnQueueQ(FrontQ(red_temp),red);
  90. DeQueueQ(red_temp);
  91. };
  92. };
  93.  
  94.  
  95. // ISPIS SVIH KLIJENATA U REDU ********************************************************************************
  96.  
  97. void ispis_red(qu *red){
  98.  
  99. cout << "\n==============================================\n";
  100. cout << " *** Ispis klijenata u redu cekanja *** \n";
  101. cout << " (prema redoslijedu dolaska u banku) \n";
  102. cout << "==============================================\n";
  103.  
  104. ispis (red);
  105. };
  106.  
  107.  
  108. // BRISANJE REDA **********************************************************************************************
  109.  
  110. void brisanje(qu *red){
  111.  
  112. char brisi;
  113.  
  114. cout << " Jeste li sigurni da zelite obrisati popis klijenata: (d/n)? ";
  115. cin >> brisi; cout << "\n\n\n\n\n";
  116.  
  117. while(!IsEmptyQ(red)){
  118. if (brisi == 'd')
  119. DeQueueQ(red);
  120. else break;
  121. };
  122. };
  123.  
  124.  
  125. // PROPUĊ TANJE STARIJIH KLIJENATA *****************************************************************************
  126.  
  127. void prednost(qu *red,qu *red_back){
  128.  
  129. elementtype temp;
  130. qu *red_temp = new qu;
  131. qu *red_temp1 = new qu;
  132. InitQ(red_temp);
  133. InitQ(red_temp1);
  134.  
  135. cout << "\n==============================================\n";
  136. cout << " *** Popis klijenata starijih od 65 godina ***\n";
  137. cout << " (propustaju se na pocetak reda) \n";
  138. cout << "==============================================\n";
  139.  
  140. while(!IsEmptyQ(red)){
  141. EnQueueQ(FrontQ(red),red_back);
  142. temp = FrontQ(red);
  143. do{
  144. if (temp.godina < 1945){
  145. EnQueueQ(FrontQ(red),red_temp);
  146. DeQueueQ(red);
  147. cout << "\n\t\t " << temp.ime_prezime;
  148. }
  149. else{
  150. EnQueueQ(FrontQ(red), red_temp1);
  151. DeQueueQ(red);}
  152. }while(false);
  153. };
  154.  
  155. cout << "\n\n\n\n==============================================\n";
  156. cout << " *** Ispis novog reda cekanja *** \n";
  157. cout << " (stariji od 65 godina su propusteni naprijed)\n";
  158. cout << "==============================================\n\n";
  159.  
  160. while(!IsEmptyQ(red_temp)){
  161. EnQueueQ(FrontQ(red_temp),red);
  162. DeQueueQ(red_temp);
  163. }
  164.  
  165. while(!IsEmptyQ(red_temp1)){
  166. EnQueueQ(FrontQ(red_temp1),red);
  167. DeQueueQ(red_temp1);
  168. }
  169.  
  170. ispis (red);
  171.  
  172. while(!IsEmptyQ(red)){
  173. DeQueueQ(red);
  174. }
  175.  
  176. while(!IsEmptyQ(red_back)){
  177. EnQueueQ(FrontQ(red_back),red);
  178. DeQueueQ(red_back);
  179. }
  180. };
  181.  
  182.  
  183. // KREDITNA SPOSOBNOST ****************************************************************************************
  184.  
  185. void kredit(qu *red, qu *red_back){
  186.  
  187. elementtype temp;
  188. qu *red_temp = new qu;
  189. InitQ(red_temp);
  190.  
  191. cout << "\n==============================================\n";
  192. cout << " *** Klijenti koji ne mogu dobiti kredit *** \n";
  193. cout << " (stanje racuna je ispod 100 kn) \n";
  194. cout << "==============================================\n\n";
  195.  
  196. while(!IsEmptyQ(red)){
  197. EnQueueQ(FrontQ(red),red_back);
  198. temp = FrontQ(red);
  199.  
  200. do{
  201. if (temp.saldo < 100 && temp.trans == 3){
  202. DeQueueQ(red);
  203. cout << "\n\t\t " << temp.ime_prezime;
  204. }
  205. else{
  206. EnQueueQ(FrontQ(red), red_temp);
  207. DeQueueQ(red);}
  208. }while(false);
  209. };
  210.  
  211. cout << "\n\n\n\n==============================================\n";
  212. cout << " *** Ispis novog reda cekanja *** \n";
  213. cout << " (Samo kreditno sposobne osobe) \n";
  214. cout << "==============================================\n\n";
  215.  
  216. while(!IsEmptyQ(red_temp)){
  217. EnQueueQ(FrontQ(red_temp),red);
  218. DeQueueQ(red_temp);
  219. }
  220.  
  221. ispis (red);
  222.  
  223. while(!IsEmptyQ(red)){
  224. DeQueueQ(red);
  225. }
  226.  
  227. while(!IsEmptyQ(red_back)){
  228. EnQueueQ(FrontQ(red_back),red);
  229. DeQueueQ(red_back);
  230. }
  231. };
  232.  
  233.  
  234. // ISPIS REDA U OBRNUTOM SLIJEDU ******************************************************************************
  235.  
  236. void ispis2(qu *red, qu *red_back){
  237.  
  238. elementtype temp;
  239.  
  240. while(!IsEmptyQ(red)){
  241. EnQueueQ(FrontQ(red),red_back);
  242. temp = FrontQ(red);
  243. DeQueueQ(red);
  244.  
  245. ispis2(red, red_back); // rekurzija
  246.  
  247. cout << "\nIme i prezime: " << temp.ime_prezime;
  248. cout << "\nGodina rodjenja: " << temp.godina;
  249. cout << "\nStanje racuna: " <<temp.saldo << " kn ";
  250. cout << "\nVrsta transakcije: " ;
  251. if(temp.trans==1)cout << "Uplata/isplata \n";
  252. else if(temp.trans==2)cout << "Placanje racuna \n";
  253. else cout << "Zahtjev za kredit \n";
  254. cout << "----------------------------------------------\n\n";
  255. };
  256. };
  257.  
  258.  
  259. // MAIN *******************************************************************************************************
  260.  
  261. int main () {
  262.  
  263. qu *red = new qu;
  264. qu *red_back = new qu;
  265. InitQ(red);
  266. InitQ(red_back);
  267.  
  268. int izbor;
  269.  
  270. do{
  271.  
  272. cout << "\n\n**********************************************************************\n\n";
  273. cout << " B A N K A V.1.0. \n\n";
  274. cout << " Autor: Anja Petrovic, 2010. \n\n";
  275. cout << "**********************************************************************\n\n\n";
  276.  
  277. cout << "======================================================================\n";
  278. cout << "1. Unos podataka o klijentima \n";
  279. cout << "2. Ispis svih klijenata u redu cekanja \n";
  280. cout << "3. Brisanje popisa klijenata \n";
  281. cout << "4. Propustanje klijenata starijih od 65 godina \n";
  282. cout << "5. Popis klijenata prema kreditnoj sposobnosti \n";
  283. cout << "6. Ispis reda cekanja na novom salteru \n";
  284. cout << "0. Izlaz iz programa \n";
  285. cout << "======================================================================\n\n\n";
  286.  
  287. cout << "Izbor: ";
  288. cin >> izbor;
  289. cout << "\n\n";
  290.  
  291. switch(izbor){
  292. case 1:unos(red);break;
  293. case 2:ispis_red(red);break;
  294. case 3:brisanje(red);break;
  295. case 4:prednost(red, red_back);break;
  296. case 5:kredit(red, red_back);break;
  297. case 6:cout << "\n==============================================\n";
  298. cout << " *** Ispis novog reda cekanja *** \n";
  299. cout << " (Nakon otvaranja novog saltera u banci) \n";
  300. cout << "==============================================\n;";
  301. ispis2(red, red_back);
  302. while(!IsEmptyQ(red_back)){
  303. EnQueueQ(FrontQ(red_back),red);
  304. DeQueueQ(red_back);}break;
  305. case 0:while(!IsEmptyQ(red)){
  306. DeQueueQ(red);};break;
  307.  
  308. default: cout << "Pogresan odabir ! Molimo ponovite unos ! \n\n" << endl << endl;
  309.  
  310. system ("pause");
  311. };
  312. }while(izbor!=0);
  313. delete red;
  314. return 0;
  315. };

Report this snippet  

You need to login to post a comment.