Created
November 22, 2016 13:43
-
-
Save PieroSilvestri/67b109aea63d490352fe6e460d581ce9 to your computer and use it in GitHub Desktop.
Esercizio Banca Senza Puntatori
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<module type="CPP_MODULE" version="4"> | |
<component name="NewModuleRootManager"> | |
<content url="file://$MODULE_DIR$"> | |
<sourceFolder url="file://$MODULE_DIR$/main.cpp" isTestSource="false" /> | |
<sourceFolder url="file://$MODULE_DIR$/CMakeLists.txt" isTestSource="false" /> | |
</content> | |
<orderEntry type="sourceFolder" forTests="false" /> | |
<orderEntry type="module-library"> | |
<library name="Header Search Paths"> | |
<CLASSES> | |
<root url="file://C:/MinGW/include" /> | |
<root url="file://C:/MinGW/mingw32/include" /> | |
<root url="file://C:/MinGW/lib/gcc/mingw32/5.3.0/include" /> | |
<root url="file://C:/MinGW/lib/gcc/mingw32/5.3.0/include-fixed" /> | |
</CLASSES> | |
<SOURCES> | |
<root url="file://C:/MinGW/include" /> | |
<root url="file://C:/MinGW/mingw32/include" /> | |
<root url="file://C:/MinGW/lib/gcc/mingw32/5.3.0/include" /> | |
<root url="file://C:/MinGW/lib/gcc/mingw32/5.3.0/include-fixed" /> | |
</SOURCES> | |
</library> | |
</orderEntry> | |
</component> | |
</module> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<project version="4"> | |
<component name="CMakeWorkspace" PROJECT_DIR="$PROJECT_DIR$" /> | |
<component name="ProjectLevelVcsManager" settingsEditedManually="false"> | |
<OptionsSetting value="true" id="Add" /> | |
<OptionsSetting value="true" id="Remove" /> | |
<OptionsSetting value="true" id="Checkout" /> | |
<OptionsSetting value="true" id="Update" /> | |
<OptionsSetting value="true" id="Status" /> | |
<OptionsSetting value="true" id="Edit" /> | |
<ConfirmationsSetting value="0" id="Add" /> | |
<ConfirmationsSetting value="0" id="Remove" /> | |
</component> | |
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<project version="4"> | |
<component name="ProjectModuleManager"> | |
<modules> | |
<module fileurl="file://$PROJECT_DIR$/.idea/Banca4.iml" filepath="$PROJECT_DIR$/.idea/Banca4.iml" /> | |
</modules> | |
</component> | |
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cmake_minimum_required(VERSION 3.6) | |
project(Banca4) | |
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") | |
set(SOURCE_FILES main.cpp) | |
add_executable(Banca4 ${SOURCE_FILES}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <string.h> | |
#include <cstdlib> | |
#include <cstring> | |
void prelievi(), menu(), versamenti(), estratto(), listaMovimenti(), saldoContabile(), risposta(); | |
void inserisciMovimento(int movimento); | |
int conto = 10000; | |
int x = 0; | |
int index = 0; | |
char risp = 'a'; | |
struct movimento{ | |
int valore; | |
char segno[50]; | |
}; | |
movimento lista_movimenti[10]; | |
int main() { | |
menu(); | |
return 0; | |
} | |
void risposta(){ | |
printf("\nVuoi tornare al menu principale (s/n)?"); | |
printf("\nScelta: "); | |
scanf("%s", &risp); | |
printf("\nHai inserito: "); | |
printf("%c", risp); | |
if(risp == 's'){ | |
menu(); | |
} | |
} | |
void menu(){ | |
printf("<--- Benvenuto nel nostro bancomat: --->\n\n"); | |
printf("****************************************"); | |
printf("\nScegli un opzione:"); | |
printf("\n 1) Prelievi"); | |
printf("\n 2) Versamenti"); | |
printf("\n 3) Estratto Conto"); | |
printf("\n 4) Exit"); | |
int scelta; | |
printf("\nScelta: "); | |
scanf ("%d",&scelta); | |
switch (scelta){ | |
case 1: | |
printf("Hai scelto 1"); | |
prelievi(); | |
break; | |
case 2: | |
printf("Hai scelto 2"); | |
versamenti(); | |
break; | |
case 3: | |
printf("Hai scelto 3"); | |
estratto(); | |
break; | |
case 4: | |
printf("Hai scelto 4"); | |
break; | |
} | |
} | |
void listaMovimenti(){ | |
printf("Lista Movimenti:\n\n"); | |
printf("*******************"); | |
for(int i = 0; i < index; i++){ | |
printf("\nValore: "); | |
printf("%d", lista_movimenti[i].valore); | |
printf(" $ \n"); | |
printf("Tipo: "); | |
printf("%s", lista_movimenti[i].segno); | |
printf("\n*******************"); | |
} | |
risposta(); | |
system("pause"); | |
} | |
void saldoContabile(){ | |
printf("\n\nIl tuo saldo disponibile e': "); | |
printf("%d", conto); | |
risposta(); | |
} | |
void prelievi(){ | |
printf("\n\n\nPrelievo:\n"); | |
printf("****************************************"); | |
printf("\nQuanto vuoi prelevare?"); | |
printf("\nPrelievo: "); | |
scanf("%d", &x); | |
if(x > conto){ | |
printf("Prelievo non disponibile\n\n\n"); | |
}else{ | |
if(x != 0){ | |
conto = conto - x; | |
lista_movimenti[index].valore = x; | |
strcpy(lista_movimenti[index].segno, "Prelievo"); | |
index++; | |
printf("\nIl tuo nuovo saldo e': "); | |
printf("%d", conto); | |
printf(" $\n\n\n"); | |
}else{ | |
printf("x e' uguale a 0\n\n\n"); | |
} | |
} | |
risposta(); | |
} | |
void versamenti(){ | |
printf("\n\n\nVersamenti:\n"); | |
printf("****************************************"); | |
printf("\nQuanto vuoi versare?"); | |
printf("\nVersamento: "); | |
scanf("%d", &x); | |
if(x != 0){ | |
conto = conto + x; | |
lista_movimenti[index].valore = x; | |
strcpy(lista_movimenti[index].segno, "Versamento"); | |
index++; | |
printf("\nIl tuo nuovo saldo e': "); | |
printf("%d", conto); | |
printf(" $\n"); | |
}else{ | |
printf("X e' uguale a zero\n\n\n"); | |
} | |
risposta(); | |
} | |
void estratto(){ | |
int valore = 0; | |
printf("\n\n\nEstratto conto:\n"); | |
printf("****************************************"); | |
printf("\nScegli un opzione: "); | |
printf("\n 1) Lista movimenti"); | |
printf("\n 2) Saldo contabile"); | |
printf("\nScelta: "); | |
scanf("%d", &valore); | |
if(valore == 1){ | |
listaMovimenti(); | |
}else if(valore == 2){ | |
saldoContabile(); | |
}else{ | |
printf("Valore inserito non valido.\n"); | |
system("pause"); | |
estratto(); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment