Advertisement
Guest User

Untitled

a guest
Dec 9th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.73 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <time.h>
  5. #include <float.h>
  6. #include <math.h>
  7. //deklaracje
  8. char Imie[20];
  9. char Nazwisko[20];
  10. int Wiek; Konto;
  11. char c;
  12. int Wybor1;
  13. int Lacznie = 0;
  14. int stawki[4][5]={
  15. {2,15,22,20,80},{3,1,3,3,3},{40,30,14,46,24},{3,2,2,3,4}
  16. };
  17. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  18. //funkcja pobierania danych
  19. void dane2() {
  20. printf("!!! TWOJE DANE !!! \n\n");
  21. printf("Imie: %s", Imie);
  22. printf("\n");
  23. printf("Nazwisko: %s", Nazwisko);
  24. printf("\n");
  25. printf("Wiek: %d", Wiek);
  26. printf("\n");
  27. printf("Twoj stan konta (zl): %d", Konto);
  28. }
  29. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  30. void dane() {
  31. printf("Podaj imie: \n");
  32. scanf("%s", &Imie);
  33. printf("\n");
  34. printf("Podaj nazwisko: \n");
  35. scanf("%s", &Nazwisko);
  36. printf("\n");
  37. printf("Podaj wiek: \n");
  38. scanf("%d", &Wiek);
  39. printf("\n");
  40. printf("Podaj twoj stan konta: \n");
  41. scanf("%d", &Konto);
  42. printf("\n");
  43. while((c=getchar())!='\n');
  44. system("cls");
  45. dane2();
  46. }
  47. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  48. //funkcja sklep - monopolowy
  49. void Monopolowy() {
  50. system("cls");
  51. int Wybor2, Inny;
  52. system("cls");
  53. srand(time(NULL));
  54. do {
  55. printf("\n\n\n");
  56. printf("Menu\n\n");
  57. printf("1. Piwo 2 zl \n");
  58. printf("2. Wino 15 zl \n");
  59. printf("3. Wodka 22 zl \n");
  60. printf("4. Bimber 20 zl\n");
  61. printf("5. Whisky 80 zl \n");
  62. printf("0. Wyjscie \n");
  63. printf("Wybierz: \n");
  64. scanf("%d",&Wybor2);
  65. c=getchar();
  66.  
  67. switch(Wybor2) {
  68. ////////////////////////////////////////////////////////////////////////////
  69. case 1:
  70. if(Konto>0){
  71. if (Wiek>=18) {
  72. printf("\n Piwo \t Koszt: %d (zl) \t"
  73. "Lacznie: %d \t Konto: %d \n",
  74. stawki[0][0], Lacznie=Lacznie+stawki[0][0], Konto=Konto-stawki[0][0]);
  75. while((c=getchar())!='\n');
  76. system("cls");
  77. }
  78. else {
  79. system("cls");
  80. printf("\n\n Alkohol od 18 lat!!! \n (ENTER aby wrocic) ");
  81. while((c=getchar())!='\n');
  82. }
  83. }
  84. else {
  85. printf("\n\n Brak pieniedzy!");
  86. while((c=getchar())!='\n');
  87. system("cls");
  88. }
  89. break;
  90. ////////////////////////////////////////////////////////////////////////////
  91. case 2:
  92. if(Konto>0){
  93. if (Wiek>=18) {
  94. printf("\n Wino \t Koszt: %d (zl) \t"
  95. "Lacznie: %d \t Konto: %d \n",
  96. stawki[0][1], Lacznie=Lacznie+stawki[0][1], Konto=Konto-stawki[0][1]);
  97. while((c=getchar())!='\n');
  98. system("cls");
  99. }
  100. else {
  101. system("cls");
  102. printf("\n\n Alkohol od 18 lat!!! \n (ENTER aby wrocic) ");
  103. while((c=getchar())!='\n');
  104. }
  105. }
  106. else {
  107. printf("\n\n Brak pieniedzy!");
  108. while((c=getchar())!='\n');
  109. system("cls");
  110. }
  111. break;
  112. ////////////////////////////////////////////////////////////////////////////
  113. case 3:
  114. if(Konto>0){
  115. if (Wiek>=18) {
  116. printf("\n Wodka \t Koszt: %d (zl) \t"
  117. "Lacznie: %d \t Konto: %d \n",
  118. stawki[0][2], Lacznie=Lacznie+stawki[0][2], Konto=Konto-stawki[0][2]);
  119. while((c=getchar())!='\n');
  120. system("cls");
  121. }
  122. else {
  123. system("cls");
  124. printf("\n\n Alkohol od 18 lat!!! \n (ENTER aby wrocic) ");
  125. while((c=getchar())!='\n');
  126. }
  127. }
  128. else {
  129. printf("\n\n Brak pieniedzy!");
  130. while((c=getchar())!='\n');
  131. system("cls");
  132. }
  133. break;
  134. ////////////////////////////////////////////////////////////////////////////
  135. case 4:
  136. if(Konto>0){
  137. if (Wiek>=18) {
  138. printf("\n Bimber \t Koszt: %d (zl) \t"
  139. "Lacznie: %d \t Konto: %d \n",
  140. stawki[0][3], Lacznie=Lacznie+stawki[0][3], Konto=Konto-stawki[0][3]);
  141. while((c=getchar())!='\n');
  142. system("cls");
  143. }
  144. else {
  145. system("cls");
  146. printf("\n\n Alkohol od 18 lat!!! \n (ENTER aby wrocic) ");
  147. while((c=getchar())!='\n');
  148. }
  149. }
  150. else {
  151. printf("\n\n Brak pieniedzy!");
  152. while((c=getchar())!='\n');
  153. system("cls");
  154. }
  155. break;
  156. ////////////////////////////////////////////////////////////////////////////
  157. case 5:
  158. if(Konto>0){
  159. if (Wiek>=18) {
  160. printf("\n Whisky \t Koszt: %d (zl) \t"
  161. "Lacznie: %d \t Konto: %d \n",
  162. stawki[0][4], Lacznie=Lacznie+stawki[0][4], Konto=Konto-stawki[0][4]);
  163. while((c=getchar())!='\n');
  164. system("cls");
  165. }
  166. else {
  167. system("cls");
  168. printf("\n\n Alkohol od 18 lat!!! \n (ENTER aby wrocic) ");
  169. while((c=getchar())!='\n');
  170. }
  171. }
  172. else {
  173. printf("\n\n Brak pieniedzy!");
  174. while((c=getchar())!='\n');
  175. system("cls");
  176. }
  177. break;
  178. ////////////////////////////////////////////////////////////////////////////
  179. case 0:
  180. printf("Dziekuje\n");
  181. break;
  182. ////////////////////////////////////////////////////////////////////////////
  183. default:
  184. printf("Bledny wybor. Powtorz \n");
  185. system("cls");
  186. break;
  187. ////////////////////////////////////////////////////////////////////////////
  188. }
  189. }
  190.  
  191. while(Wybor2!=0);
  192. printf("\n");
  193. printf("Na koncie zostalo: %d zl \t Zaplacono lacznie: %d zl", Konto, Lacznie);
  194. printf("\n\n Inny sklep? \n\n 1 - TAK \t 2 - NIE \n\n");
  195. scanf("%d", &Inny);
  196. if(Inny==1) menu();
  197. else if (Inny==2) {
  198. system("cls");
  199. printf("\n\n To czesc :)");
  200. while((c=getchar())!='\n');
  201. return 0;
  202. }
  203. else {
  204. while((c=getchar())!='\n');
  205. system("cls");
  206. printf("\n\n BLAD!!!");
  207. while((c=getchar())!='\n');
  208. menu();}
  209. }
  210. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  211. //funkcja sklep - piekarnia
  212. void Piekarnia() {
  213. system("cls");
  214. int Wybor2, Inny;
  215. system("cls");
  216. srand(time(NULL));
  217. do {
  218. printf("\n\n\n");
  219. printf("Menu\n\n");
  220. printf("1. Chleb krojony 3 zl \n");
  221. printf("2. 5 bulek kajzerek 1 zl \n");
  222. printf("3. Paczek z dzemem 3 zl \n");
  223. printf("4. Paczek z czekolada 3 zl\n");
  224. printf("5. Rogalik 3 zl \n");
  225. printf("0. Wyjscie \n");
  226. printf("Wybierz: \n");
  227. scanf("%d",&Wybor2);
  228. c=getchar();
  229. switch(Wybor2) {
  230. ////////////////////////////////////////////////////////////////////////////
  231. case 1:
  232. if(Konto>0){
  233. printf("\n Chleb krojony \t Koszt: %d (zl) \t"
  234. "Lacznie: %d \t Konto: %d \n",
  235. stawki[1][0], Lacznie=Lacznie+stawki[1][0], Konto=Konto-stawki[1][0]);
  236. while((c=getchar())!='\n');
  237. system("cls");
  238. }
  239. else {
  240. printf("\n\n Brak pieniedzy!");
  241. while((c=getchar())!='\n');
  242. system("cls");
  243. }
  244. break;
  245. ////////////////////////////////////////////////////////////////////////////
  246. case 2:
  247. if(Konto>0){
  248. printf("\n 5 bulek kajzerek \t Koszt: %d (zl) \t"
  249. "Lacznie: %d \t Konto: %d \n",
  250. stawki[1][1], Lacznie=Lacznie+stawki[1][1], Konto=Konto-stawki[1][1]);
  251. while((c=getchar())!='\n');
  252. system("cls");
  253. }
  254. else {
  255. printf("\n\n Brak pieniedzy!");
  256. while((c=getchar())!='\n');
  257. system("cls");
  258. }
  259. break;
  260. ////////////////////////////////////////////////////////////////////////////
  261. case 3:
  262. if(Konto>0){
  263. printf("\n Paczek z dzemem \t Koszt: %d (zl) \t"
  264. "Lacznie: %d \t Konto: %d \n",
  265. stawki[1][2], Lacznie=Lacznie+stawki[1][2], Konto=Konto-stawki[1][2]);
  266. while((c=getchar())!='\n');
  267. system("cls");
  268. }
  269. else {
  270. printf("\n\n Brak pieniedzy!");
  271. while((c=getchar())!='\n');
  272. system("cls");
  273. }
  274. break;
  275. ////////////////////////////////////////////////////////////////////////////
  276. case 4:
  277. if(Konto>0){
  278. printf("\n Paczek z czekolada \t Koszt: %d (zl) \t"
  279. "Lacznie: %d \t Konto: %d \n",
  280. stawki[1][3], Lacznie=Lacznie+stawki[1][3], Konto=Konto-stawki[1][3]);
  281. while((c=getchar())!='\n');
  282. system("cls");
  283. }
  284. else {
  285. printf("\n\n Brak pieniedzy!");
  286. while((c=getchar())!='\n');
  287. system("cls");
  288. }
  289. break;
  290. ////////////////////////////////////////////////////////////////////////////
  291. case 5:
  292. if(Konto>0){
  293. printf("\n Rogalik \t Koszt: %d (zl) \t"
  294. "Lacznie: %d \t Konto: %d \n",
  295. stawki[1][4], Lacznie=Lacznie+stawki[1][4], Konto=Konto-stawki[1][4]);
  296. while((c=getchar())!='\n');
  297. system("cls");
  298. }
  299. else {
  300. printf("\n\n Brak pieniedzy!");
  301. while((c=getchar())!='\n');
  302. system("cls");
  303. }
  304. break;
  305. ////////////////////////////////////////////////////////////////////////////
  306. case 0:
  307. printf("Dziekuje\n");
  308. break;
  309. ////////////////////////////////////////////////////////////////////////////
  310. default:
  311. printf("Bledny wybor. Powtorz \n");
  312. system("cls");
  313. break;
  314. ////////////////////////////////////////////////////////////////////////////
  315. }
  316. }
  317. while(Wybor2!=0);
  318. printf("\n");
  319. if(Konto<0){
  320. printf("Zaplacono lacznie: %d zl \t Jestes winny galerii: %d zl", Lacznie, Konto*-1);
  321. }
  322. else
  323. printf("Na koncie zostalo: %d zl \t Zaplacono lacznie: %d zl", Konto, Lacznie);
  324. printf("\n\n Inny sklep? \n\n 1 - TAK \t 2 - NIE \n\n");
  325. scanf("%d", &Inny);
  326. if(Inny==1) menu();
  327. else if (Inny==2) return 0;
  328. else {
  329. while((c=getchar())!='\n');
  330. system("cls");
  331. printf("\n\n BLAD!!!");
  332. while((c=getchar())!='\n');
  333. menu();}
  334. }
  335. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  336. //funkcja sklep - mięsny
  337. void Miesny() {
  338. system("cls");
  339. int Wybor2, Inny;
  340. system("cls");
  341. srand(time(NULL));
  342. do {
  343. printf("\n\n\n");
  344. printf("Menu\n\n");
  345. printf("1. Baleron wedzony 40 zl/kg \n");
  346. printf("2. Golen wolowa z koscia 30 zl/kg \n");
  347. printf("3. Golonka wieprzowa tylna 14 zl/kg \n");
  348. printf("4. Kabanos wieprzowy 46 zl/kg \n");
  349. printf("5. Karkowka bez kosci 24 zl/kg \n");
  350. printf("0. Wyjscie \n");
  351. printf("Wybierz: \n");
  352. scanf("%d",&Wybor2);
  353. c=getchar();
  354. switch(Wybor2) {
  355. ////////////////////////////////////////////////////////////////////////////
  356. case 1:
  357. if(Konto>0){
  358. printf("\n Baleron wedzony \t Koszt: %d (zl) \t"
  359. "Lacznie: %d \t Konto: %d \n",
  360. stawki[2][0], Lacznie=Lacznie+stawki[2][0], Konto=Konto-stawki[2][0]);
  361. while((c=getchar())!='\n');
  362. system("cls");
  363. }
  364. else {
  365. printf("\n\n Brak pieniedzy!");
  366. while((c=getchar())!='\n');
  367. system("cls");
  368. }
  369. break;
  370. ////////////////////////////////////////////////////////////////////////////
  371. case 2:
  372. if(Konto>0){
  373. printf("\n Golen wolowa z koscia \t Koszt: %d (zl) \t"
  374. "Lacznie: %d \t Konto: %d \n",
  375. stawki[2][1], Lacznie=Lacznie+stawki[2][1], Konto=Konto-stawki[2][1]);
  376. while((c=getchar())!='\n');
  377. system("cls");
  378. }
  379. else {
  380. printf("\n\n Brak pieniedzy!");
  381. while((c=getchar())!='\n');
  382. system("cls");
  383. }
  384. break;
  385. ////////////////////////////////////////////////////////////////////////////
  386. case 3:
  387. if(Konto>0){
  388. printf("\n Golonka wieprzowa tylna \t Koszt: %d (zl) \t"
  389. "Lacznie: %d \t Konto: %d \n",
  390. stawki[2][2], Lacznie=Lacznie+stawki[2][2], Konto=Konto-stawki[2][2]);
  391. while((c=getchar())!='\n');
  392. system("cls");
  393. }
  394. else {
  395. printf("\n\n Brak pieniedzy!");
  396. while((c=getchar())!='\n');
  397. system("cls");
  398. }
  399. break;
  400. ////////////////////////////////////////////////////////////////////////////
  401. case 4:
  402. if(Konto>0){
  403. printf("\n Kabanos wieprzowy \t Koszt: %d (zl) \t"
  404. "Lacznie: %d \t Konto: %d \n",
  405. stawki[2][3], Lacznie=Lacznie+stawki[2][3], Konto=Konto-stawki[2][3]);
  406. while((c=getchar())!='\n');
  407. system("cls");
  408. }
  409. else {
  410. printf("\n\n Brak pieniedzy!");
  411. while((c=getchar())!='\n');
  412. system("cls");
  413. }
  414. break;
  415. ////////////////////////////////////////////////////////////////////////////
  416. case 5:
  417. if(Konto>0){
  418. printf("\n Karkowka bez kosci \t Koszt: %d (zl) \t"
  419. "Lacznie: %d \t Konto: %d \n",
  420. stawki[2][4], Lacznie=Lacznie+stawki[2][4], Konto=Konto-stawki[2][4]);
  421. while((c=getchar())!='\n');
  422. system("cls");
  423. }
  424. else {
  425. printf("\n\n Brak pieniedzy!");
  426. while((c=getchar())!='\n');
  427. system("cls");
  428. }
  429. break;
  430. ////////////////////////////////////////////////////////////////////////////
  431. case 0:
  432. printf("Dziekuje\n");
  433. break;
  434. ////////////////////////////////////////////////////////////////////////////
  435. default:
  436. printf("Bledny wybor. Powtorz \n");
  437. system("cls");
  438. break;
  439. ////////////////////////////////////////////////////////////////////////////
  440. }
  441. }
  442. while(Wybor2!=0);
  443. printf("\n");
  444. printf("Na koncie zostalo: %d zl \t Zaplacono lacznie: %d zl", Konto, Lacznie);
  445. printf("\n\n Inny sklep? \n\n 1 - TAK \t 2 - NIE \n\n");
  446. scanf("%d", &Inny);
  447. if(Inny==1) menu();
  448. else if (Inny==2) return 0;
  449. else {
  450. while((c=getchar())!='\n');
  451. system("cls");
  452. printf("\n\n BLAD!!!");
  453. while((c=getchar())!='\n');
  454. menu();}
  455. }
  456. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  457. //funkcja sklep - kiosk
  458. void Kiosk() {
  459. system("cls");
  460. int Wybor2, Inny;
  461. system("cls");
  462. srand(time(NULL));
  463. do {
  464. printf("\n\n\n");
  465. printf("Menu\n\n");
  466. printf("1. Gazeta 3 zl \n");
  467. printf("2. Pepsi w puszce 2 zl \n");
  468. printf("3. Bilet 15 minut 2 zl \n");
  469. printf("4. Bilet 30 minut 3 zl\n");
  470. printf("5. Baton Snickers podwojny 4 zl \n");
  471. printf("0. Wyjscie \n");
  472. printf("Wybierz: \n");
  473. scanf("%d",&Wybor2);
  474. c=getchar();
  475. switch(Wybor2) {
  476. ////////////////////////////////////////////////////////////////////////////
  477. case 1:
  478. if(Konto>0){
  479. printf("\n Gazeta \t Koszt: %d (zl) \t"
  480. "Lacznie: %d \t Konto: %d \n",
  481. stawki[3][0], Lacznie=Lacznie+stawki[3][0], Konto=Konto-stawki[3][0]);
  482. while((c=getchar())!='\n');
  483. system("cls");
  484. }
  485. else {
  486. printf("\n\n Brak pieniedzy!");
  487. while((c=getchar())!='\n');
  488. system("cls");
  489. }
  490. break;
  491. ////////////////////////////////////////////////////////////////////////////
  492. case 2:
  493. if(Konto>0){
  494. printf("\n Pepsi w puszce \t Koszt: %d (zl) \t"
  495. "Lacznie: %d \t Konto: %d \n",
  496. stawki[3][1], Lacznie=Lacznie+stawki[3][1], Konto=Konto-stawki[3][1]);
  497. while((c=getchar())!='\n');
  498. system("cls");
  499. }
  500. else {
  501. printf("\n\n Brak pieniedzy!");
  502. while((c=getchar())!='\n');
  503. system("cls");
  504. }
  505. break;
  506. ////////////////////////////////////////////////////////////////////////////
  507. case 3:
  508. if(Konto>0){
  509. printf("\n Bilet 15 minut \t Koszt: %d (zl) \t"
  510. "Lacznie: %d \t Konto: %d \n",
  511. stawki[3][2], Lacznie=Lacznie+stawki[3][2], Konto=Konto-stawki[3][2]);
  512. while((c=getchar())!='\n');
  513. system("cls");
  514. }
  515. else {
  516. printf("\n\n Brak pieniedzy!");
  517. while((c=getchar())!='\n');
  518. system("cls");
  519. }
  520. break;
  521. ////////////////////////////////////////////////////////////////////////////
  522. case 4:
  523. if(Konto>0){
  524. printf("\n Bilet 30 minut \t Koszt: %d (zl) \t"
  525. "Lacznie: %d \t Konto: %d \n",
  526. stawki[3][3], Lacznie=Lacznie+stawki[3][3], Konto=Konto-stawki[3][3]);
  527. while((c=getchar())!='\n');
  528. system("cls");
  529. }
  530. else {
  531. printf("\n\n Brak pieniedzy!");
  532. while((c=getchar())!='\n');
  533. system("cls");
  534. }
  535. break;
  536. ////////////////////////////////////////////////////////////////////////////
  537. case 5:
  538. if(Konto>0){
  539. printf("\n Baton Snickers podwojny \t Koszt: %d (zl) \t"
  540. "Lacznie: %d \t Konto: %d \n",
  541. stawki[3][4], Lacznie=Lacznie+stawki[3][4], Konto=Konto-stawki[3][4]);
  542. while((c=getchar())!='\n');
  543. system("cls");
  544. }
  545. else {
  546. printf("\n\n Brak pieniedzy!");
  547. while((c=getchar())!='\n');
  548. system("cls");
  549. }
  550. break;
  551. ////////////////////////////////////////////////////////////////////////////
  552. case 0:
  553. printf("Dziekuje\n");
  554. break;
  555. ////////////////////////////////////////////////////////////////////////////
  556. default:
  557. printf("Bledny wybor. Powtorz \n");
  558. system("cls");
  559. break;
  560. ////////////////////////////////////////////////////////////////////////////
  561. }
  562. }
  563. while(Wybor2!=0);
  564. printf("\n");
  565. printf("Na koncie zostalo: %d zl \t Zaplacono lacznie: %d zl", Konto, Lacznie);
  566. printf("\n\n Inny sklep? \n\n 1 - TAK \t 2 - NIE \n\n");
  567. scanf("%d", &Inny);
  568. if(Inny==1) menu();
  569. else if (Inny==2) return 0;
  570. else {
  571. while((c=getchar())!='\n');
  572. system("cls");
  573. printf("\n\n BLAD!!!");
  574. while((c=getchar())!='\n');
  575. menu();}
  576. }
  577. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  578. //funkcja menu - wybór sklepu
  579. void menu(){
  580. system("cls");
  581. dane2();
  582. printf("\n\n\n");
  583. printf("Rynek - zakupy \n\n");
  584. printf("1. Monopolowy \n");
  585. printf("2. Piekarnia \n");
  586. printf("3. Miesny \n");
  587. printf("4. Kiosk \n");
  588. printf("0. Niczego nie potrzebuje \n\n");
  589. printf("Wybierz: ");
  590. scanf("%d", &Wybor1);
  591. if (Wybor1==1) Monopolowy();
  592. else if (Wybor1==2) Piekarnia();
  593. else if (Wybor1==3) Miesny();
  594. else if (Wybor1==4) Kiosk();
  595. else if (Wybor1==0) {
  596. system("cls");
  597. printf("To czesc.");
  598. while((c=getchar())!='\n');
  599. return 0;
  600. }
  601. else {
  602. menu();
  603. }
  604. }
  605. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  606. //Cialo glowne
  607. int main(){
  608. dane();
  609. while((c=getchar())!='\n');
  610. menu();
  611. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement