Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <time.h>
- #include <float.h>
- #include <math.h>
- //deklaracje
- char Imie[20];
- char Nazwisko[20];
- int Wiek; Konto;
- char c;
- int Wybor1;
- int Lacznie = 0;
- int stawki[4][5]={
- {2,15,22,20,80},{3,1,3,3,3},{40,30,14,46,24},{3,2,2,3,4}
- };
- //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- //funkcja pobierania danych
- void dane2() {
- printf("!!! TWOJE DANE !!! \n\n");
- printf("Imie: %s", Imie);
- printf("\n");
- printf("Nazwisko: %s", Nazwisko);
- printf("\n");
- printf("Wiek: %d", Wiek);
- printf("\n");
- printf("Twoj stan konta (zl): %d", Konto);
- }
- //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- void dane() {
- printf("Podaj imie: \n");
- scanf("%s", &Imie);
- printf("\n");
- printf("Podaj nazwisko: \n");
- scanf("%s", &Nazwisko);
- printf("\n");
- printf("Podaj wiek: \n");
- scanf("%d", &Wiek);
- printf("\n");
- printf("Podaj twoj stan konta: \n");
- scanf("%d", &Konto);
- printf("\n");
- while((c=getchar())!='\n');
- system("cls");
- dane2();
- }
- //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- //funkcja sklep - monopolowy
- void Monopolowy() {
- system("cls");
- int Wybor2, Inny;
- system("cls");
- srand(time(NULL));
- do {
- printf("\n\n\n");
- printf("Menu\n\n");
- printf("1. Piwo 2 zl \n");
- printf("2. Wino 15 zl \n");
- printf("3. Wodka 22 zl \n");
- printf("4. Bimber 20 zl\n");
- printf("5. Whisky 80 zl \n");
- printf("0. Wyjscie \n");
- printf("Wybierz: \n");
- scanf("%d",&Wybor2);
- c=getchar();
- switch(Wybor2) {
- ////////////////////////////////////////////////////////////////////////////
- case 1:
- if(Konto>0){
- if (Wiek>=18) {
- printf("\n Piwo \t Koszt: %d (zl) \t"
- "Lacznie: %d \t Konto: %d \n",
- stawki[0][0], Lacznie=Lacznie+stawki[0][0], Konto=Konto-stawki[0][0]);
- while((c=getchar())!='\n');
- system("cls");
- }
- else {
- system("cls");
- printf("\n\n Alkohol od 18 lat!!! \n (ENTER aby wrocic) ");
- while((c=getchar())!='\n');
- }
- }
- else {
- printf("\n\n Brak pieniedzy!");
- while((c=getchar())!='\n');
- system("cls");
- }
- break;
- ////////////////////////////////////////////////////////////////////////////
- case 2:
- if(Konto>0){
- if (Wiek>=18) {
- printf("\n Wino \t Koszt: %d (zl) \t"
- "Lacznie: %d \t Konto: %d \n",
- stawki[0][1], Lacznie=Lacznie+stawki[0][1], Konto=Konto-stawki[0][1]);
- while((c=getchar())!='\n');
- system("cls");
- }
- else {
- system("cls");
- printf("\n\n Alkohol od 18 lat!!! \n (ENTER aby wrocic) ");
- while((c=getchar())!='\n');
- }
- }
- else {
- printf("\n\n Brak pieniedzy!");
- while((c=getchar())!='\n');
- system("cls");
- }
- break;
- ////////////////////////////////////////////////////////////////////////////
- case 3:
- if(Konto>0){
- if (Wiek>=18) {
- printf("\n Wodka \t Koszt: %d (zl) \t"
- "Lacznie: %d \t Konto: %d \n",
- stawki[0][2], Lacznie=Lacznie+stawki[0][2], Konto=Konto-stawki[0][2]);
- while((c=getchar())!='\n');
- system("cls");
- }
- else {
- system("cls");
- printf("\n\n Alkohol od 18 lat!!! \n (ENTER aby wrocic) ");
- while((c=getchar())!='\n');
- }
- }
- else {
- printf("\n\n Brak pieniedzy!");
- while((c=getchar())!='\n');
- system("cls");
- }
- break;
- ////////////////////////////////////////////////////////////////////////////
- case 4:
- if(Konto>0){
- if (Wiek>=18) {
- printf("\n Bimber \t Koszt: %d (zl) \t"
- "Lacznie: %d \t Konto: %d \n",
- stawki[0][3], Lacznie=Lacznie+stawki[0][3], Konto=Konto-stawki[0][3]);
- while((c=getchar())!='\n');
- system("cls");
- }
- else {
- system("cls");
- printf("\n\n Alkohol od 18 lat!!! \n (ENTER aby wrocic) ");
- while((c=getchar())!='\n');
- }
- }
- else {
- printf("\n\n Brak pieniedzy!");
- while((c=getchar())!='\n');
- system("cls");
- }
- break;
- ////////////////////////////////////////////////////////////////////////////
- case 5:
- if(Konto>0){
- if (Wiek>=18) {
- printf("\n Whisky \t Koszt: %d (zl) \t"
- "Lacznie: %d \t Konto: %d \n",
- stawki[0][4], Lacznie=Lacznie+stawki[0][4], Konto=Konto-stawki[0][4]);
- while((c=getchar())!='\n');
- system("cls");
- }
- else {
- system("cls");
- printf("\n\n Alkohol od 18 lat!!! \n (ENTER aby wrocic) ");
- while((c=getchar())!='\n');
- }
- }
- else {
- printf("\n\n Brak pieniedzy!");
- while((c=getchar())!='\n');
- system("cls");
- }
- break;
- ////////////////////////////////////////////////////////////////////////////
- case 0:
- printf("Dziekuje\n");
- break;
- ////////////////////////////////////////////////////////////////////////////
- default:
- printf("Bledny wybor. Powtorz \n");
- system("cls");
- break;
- ////////////////////////////////////////////////////////////////////////////
- }
- }
- while(Wybor2!=0);
- printf("\n");
- printf("Na koncie zostalo: %d zl \t Zaplacono lacznie: %d zl", Konto, Lacznie);
- printf("\n\n Inny sklep? \n\n 1 - TAK \t 2 - NIE \n\n");
- scanf("%d", &Inny);
- if(Inny==1) menu();
- else if (Inny==2) {
- system("cls");
- printf("\n\n To czesc :)");
- while((c=getchar())!='\n');
- return 0;
- }
- else {
- while((c=getchar())!='\n');
- system("cls");
- printf("\n\n BLAD!!!");
- while((c=getchar())!='\n');
- menu();}
- }
- //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- //funkcja sklep - piekarnia
- void Piekarnia() {
- system("cls");
- int Wybor2, Inny;
- system("cls");
- srand(time(NULL));
- do {
- printf("\n\n\n");
- printf("Menu\n\n");
- printf("1. Chleb krojony 3 zl \n");
- printf("2. 5 bulek kajzerek 1 zl \n");
- printf("3. Paczek z dzemem 3 zl \n");
- printf("4. Paczek z czekolada 3 zl\n");
- printf("5. Rogalik 3 zl \n");
- printf("0. Wyjscie \n");
- printf("Wybierz: \n");
- scanf("%d",&Wybor2);
- c=getchar();
- switch(Wybor2) {
- ////////////////////////////////////////////////////////////////////////////
- case 1:
- if(Konto>0){
- printf("\n Chleb krojony \t Koszt: %d (zl) \t"
- "Lacznie: %d \t Konto: %d \n",
- stawki[1][0], Lacznie=Lacznie+stawki[1][0], Konto=Konto-stawki[1][0]);
- while((c=getchar())!='\n');
- system("cls");
- }
- else {
- printf("\n\n Brak pieniedzy!");
- while((c=getchar())!='\n');
- system("cls");
- }
- break;
- ////////////////////////////////////////////////////////////////////////////
- case 2:
- if(Konto>0){
- printf("\n 5 bulek kajzerek \t Koszt: %d (zl) \t"
- "Lacznie: %d \t Konto: %d \n",
- stawki[1][1], Lacznie=Lacznie+stawki[1][1], Konto=Konto-stawki[1][1]);
- while((c=getchar())!='\n');
- system("cls");
- }
- else {
- printf("\n\n Brak pieniedzy!");
- while((c=getchar())!='\n');
- system("cls");
- }
- break;
- ////////////////////////////////////////////////////////////////////////////
- case 3:
- if(Konto>0){
- printf("\n Paczek z dzemem \t Koszt: %d (zl) \t"
- "Lacznie: %d \t Konto: %d \n",
- stawki[1][2], Lacznie=Lacznie+stawki[1][2], Konto=Konto-stawki[1][2]);
- while((c=getchar())!='\n');
- system("cls");
- }
- else {
- printf("\n\n Brak pieniedzy!");
- while((c=getchar())!='\n');
- system("cls");
- }
- break;
- ////////////////////////////////////////////////////////////////////////////
- case 4:
- if(Konto>0){
- printf("\n Paczek z czekolada \t Koszt: %d (zl) \t"
- "Lacznie: %d \t Konto: %d \n",
- stawki[1][3], Lacznie=Lacznie+stawki[1][3], Konto=Konto-stawki[1][3]);
- while((c=getchar())!='\n');
- system("cls");
- }
- else {
- printf("\n\n Brak pieniedzy!");
- while((c=getchar())!='\n');
- system("cls");
- }
- break;
- ////////////////////////////////////////////////////////////////////////////
- case 5:
- if(Konto>0){
- printf("\n Rogalik \t Koszt: %d (zl) \t"
- "Lacznie: %d \t Konto: %d \n",
- stawki[1][4], Lacznie=Lacznie+stawki[1][4], Konto=Konto-stawki[1][4]);
- while((c=getchar())!='\n');
- system("cls");
- }
- else {
- printf("\n\n Brak pieniedzy!");
- while((c=getchar())!='\n');
- system("cls");
- }
- break;
- ////////////////////////////////////////////////////////////////////////////
- case 0:
- printf("Dziekuje\n");
- break;
- ////////////////////////////////////////////////////////////////////////////
- default:
- printf("Bledny wybor. Powtorz \n");
- system("cls");
- break;
- ////////////////////////////////////////////////////////////////////////////
- }
- }
- while(Wybor2!=0);
- printf("\n");
- if(Konto<0){
- printf("Zaplacono lacznie: %d zl \t Jestes winny galerii: %d zl", Lacznie, Konto*-1);
- }
- else
- printf("Na koncie zostalo: %d zl \t Zaplacono lacznie: %d zl", Konto, Lacznie);
- printf("\n\n Inny sklep? \n\n 1 - TAK \t 2 - NIE \n\n");
- scanf("%d", &Inny);
- if(Inny==1) menu();
- else if (Inny==2) return 0;
- else {
- while((c=getchar())!='\n');
- system("cls");
- printf("\n\n BLAD!!!");
- while((c=getchar())!='\n');
- menu();}
- }
- //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- //funkcja sklep - mięsny
- void Miesny() {
- system("cls");
- int Wybor2, Inny;
- system("cls");
- srand(time(NULL));
- do {
- printf("\n\n\n");
- printf("Menu\n\n");
- printf("1. Baleron wedzony 40 zl/kg \n");
- printf("2. Golen wolowa z koscia 30 zl/kg \n");
- printf("3. Golonka wieprzowa tylna 14 zl/kg \n");
- printf("4. Kabanos wieprzowy 46 zl/kg \n");
- printf("5. Karkowka bez kosci 24 zl/kg \n");
- printf("0. Wyjscie \n");
- printf("Wybierz: \n");
- scanf("%d",&Wybor2);
- c=getchar();
- switch(Wybor2) {
- ////////////////////////////////////////////////////////////////////////////
- case 1:
- if(Konto>0){
- printf("\n Baleron wedzony \t Koszt: %d (zl) \t"
- "Lacznie: %d \t Konto: %d \n",
- stawki[2][0], Lacznie=Lacznie+stawki[2][0], Konto=Konto-stawki[2][0]);
- while((c=getchar())!='\n');
- system("cls");
- }
- else {
- printf("\n\n Brak pieniedzy!");
- while((c=getchar())!='\n');
- system("cls");
- }
- break;
- ////////////////////////////////////////////////////////////////////////////
- case 2:
- if(Konto>0){
- printf("\n Golen wolowa z koscia \t Koszt: %d (zl) \t"
- "Lacznie: %d \t Konto: %d \n",
- stawki[2][1], Lacznie=Lacznie+stawki[2][1], Konto=Konto-stawki[2][1]);
- while((c=getchar())!='\n');
- system("cls");
- }
- else {
- printf("\n\n Brak pieniedzy!");
- while((c=getchar())!='\n');
- system("cls");
- }
- break;
- ////////////////////////////////////////////////////////////////////////////
- case 3:
- if(Konto>0){
- printf("\n Golonka wieprzowa tylna \t Koszt: %d (zl) \t"
- "Lacznie: %d \t Konto: %d \n",
- stawki[2][2], Lacznie=Lacznie+stawki[2][2], Konto=Konto-stawki[2][2]);
- while((c=getchar())!='\n');
- system("cls");
- }
- else {
- printf("\n\n Brak pieniedzy!");
- while((c=getchar())!='\n');
- system("cls");
- }
- break;
- ////////////////////////////////////////////////////////////////////////////
- case 4:
- if(Konto>0){
- printf("\n Kabanos wieprzowy \t Koszt: %d (zl) \t"
- "Lacznie: %d \t Konto: %d \n",
- stawki[2][3], Lacznie=Lacznie+stawki[2][3], Konto=Konto-stawki[2][3]);
- while((c=getchar())!='\n');
- system("cls");
- }
- else {
- printf("\n\n Brak pieniedzy!");
- while((c=getchar())!='\n');
- system("cls");
- }
- break;
- ////////////////////////////////////////////////////////////////////////////
- case 5:
- if(Konto>0){
- printf("\n Karkowka bez kosci \t Koszt: %d (zl) \t"
- "Lacznie: %d \t Konto: %d \n",
- stawki[2][4], Lacznie=Lacznie+stawki[2][4], Konto=Konto-stawki[2][4]);
- while((c=getchar())!='\n');
- system("cls");
- }
- else {
- printf("\n\n Brak pieniedzy!");
- while((c=getchar())!='\n');
- system("cls");
- }
- break;
- ////////////////////////////////////////////////////////////////////////////
- case 0:
- printf("Dziekuje\n");
- break;
- ////////////////////////////////////////////////////////////////////////////
- default:
- printf("Bledny wybor. Powtorz \n");
- system("cls");
- break;
- ////////////////////////////////////////////////////////////////////////////
- }
- }
- while(Wybor2!=0);
- printf("\n");
- printf("Na koncie zostalo: %d zl \t Zaplacono lacznie: %d zl", Konto, Lacznie);
- printf("\n\n Inny sklep? \n\n 1 - TAK \t 2 - NIE \n\n");
- scanf("%d", &Inny);
- if(Inny==1) menu();
- else if (Inny==2) return 0;
- else {
- while((c=getchar())!='\n');
- system("cls");
- printf("\n\n BLAD!!!");
- while((c=getchar())!='\n');
- menu();}
- }
- //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- //funkcja sklep - kiosk
- void Kiosk() {
- system("cls");
- int Wybor2, Inny;
- system("cls");
- srand(time(NULL));
- do {
- printf("\n\n\n");
- printf("Menu\n\n");
- printf("1. Gazeta 3 zl \n");
- printf("2. Pepsi w puszce 2 zl \n");
- printf("3. Bilet 15 minut 2 zl \n");
- printf("4. Bilet 30 minut 3 zl\n");
- printf("5. Baton Snickers podwojny 4 zl \n");
- printf("0. Wyjscie \n");
- printf("Wybierz: \n");
- scanf("%d",&Wybor2);
- c=getchar();
- switch(Wybor2) {
- ////////////////////////////////////////////////////////////////////////////
- case 1:
- if(Konto>0){
- printf("\n Gazeta \t Koszt: %d (zl) \t"
- "Lacznie: %d \t Konto: %d \n",
- stawki[3][0], Lacznie=Lacznie+stawki[3][0], Konto=Konto-stawki[3][0]);
- while((c=getchar())!='\n');
- system("cls");
- }
- else {
- printf("\n\n Brak pieniedzy!");
- while((c=getchar())!='\n');
- system("cls");
- }
- break;
- ////////////////////////////////////////////////////////////////////////////
- case 2:
- if(Konto>0){
- printf("\n Pepsi w puszce \t Koszt: %d (zl) \t"
- "Lacznie: %d \t Konto: %d \n",
- stawki[3][1], Lacznie=Lacznie+stawki[3][1], Konto=Konto-stawki[3][1]);
- while((c=getchar())!='\n');
- system("cls");
- }
- else {
- printf("\n\n Brak pieniedzy!");
- while((c=getchar())!='\n');
- system("cls");
- }
- break;
- ////////////////////////////////////////////////////////////////////////////
- case 3:
- if(Konto>0){
- printf("\n Bilet 15 minut \t Koszt: %d (zl) \t"
- "Lacznie: %d \t Konto: %d \n",
- stawki[3][2], Lacznie=Lacznie+stawki[3][2], Konto=Konto-stawki[3][2]);
- while((c=getchar())!='\n');
- system("cls");
- }
- else {
- printf("\n\n Brak pieniedzy!");
- while((c=getchar())!='\n');
- system("cls");
- }
- break;
- ////////////////////////////////////////////////////////////////////////////
- case 4:
- if(Konto>0){
- printf("\n Bilet 30 minut \t Koszt: %d (zl) \t"
- "Lacznie: %d \t Konto: %d \n",
- stawki[3][3], Lacznie=Lacznie+stawki[3][3], Konto=Konto-stawki[3][3]);
- while((c=getchar())!='\n');
- system("cls");
- }
- else {
- printf("\n\n Brak pieniedzy!");
- while((c=getchar())!='\n');
- system("cls");
- }
- break;
- ////////////////////////////////////////////////////////////////////////////
- case 5:
- if(Konto>0){
- printf("\n Baton Snickers podwojny \t Koszt: %d (zl) \t"
- "Lacznie: %d \t Konto: %d \n",
- stawki[3][4], Lacznie=Lacznie+stawki[3][4], Konto=Konto-stawki[3][4]);
- while((c=getchar())!='\n');
- system("cls");
- }
- else {
- printf("\n\n Brak pieniedzy!");
- while((c=getchar())!='\n');
- system("cls");
- }
- break;
- ////////////////////////////////////////////////////////////////////////////
- case 0:
- printf("Dziekuje\n");
- break;
- ////////////////////////////////////////////////////////////////////////////
- default:
- printf("Bledny wybor. Powtorz \n");
- system("cls");
- break;
- ////////////////////////////////////////////////////////////////////////////
- }
- }
- while(Wybor2!=0);
- printf("\n");
- printf("Na koncie zostalo: %d zl \t Zaplacono lacznie: %d zl", Konto, Lacznie);
- printf("\n\n Inny sklep? \n\n 1 - TAK \t 2 - NIE \n\n");
- scanf("%d", &Inny);
- if(Inny==1) menu();
- else if (Inny==2) return 0;
- else {
- while((c=getchar())!='\n');
- system("cls");
- printf("\n\n BLAD!!!");
- while((c=getchar())!='\n');
- menu();}
- }
- //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- //funkcja menu - wybór sklepu
- void menu(){
- system("cls");
- dane2();
- printf("\n\n\n");
- printf("Rynek - zakupy \n\n");
- printf("1. Monopolowy \n");
- printf("2. Piekarnia \n");
- printf("3. Miesny \n");
- printf("4. Kiosk \n");
- printf("0. Niczego nie potrzebuje \n\n");
- printf("Wybierz: ");
- scanf("%d", &Wybor1);
- if (Wybor1==1) Monopolowy();
- else if (Wybor1==2) Piekarnia();
- else if (Wybor1==3) Miesny();
- else if (Wybor1==4) Kiosk();
- else if (Wybor1==0) {
- system("cls");
- printf("To czesc.");
- while((c=getchar())!='\n');
- return 0;
- }
- else {
- menu();
- }
- }
- //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- //Cialo glowne
- int main(){
- dane();
- while((c=getchar())!='\n');
- menu();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement