S
Hier A-Style formattiert und mit Code-Tags (bitte lese das):
#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <conio.h>
#include <windows.h>
using namespace std;
struct girokonto
{
double kontostand;
int maxkontostand;
double dispo;
int kontonummer;
char kontoinhaber[20];
double einzahlen;
int auszahlen;
int kontenzaehler;
int PIN;
};
void anlegenKonto(girokonto&);
void eingabeDaten();
void ausgabeDaten(girokonto, girokonto);
void einzahlen(girokonto&, girokonto&);
void auszahlen(girokonto&, girokonto&);
void beratung(girokonto);
void dispoOut(girokonto&);
void kundendatenEingabe(girokonto);
void speichern(girokonto&);
void anlegenKonto(girokonto &a)
{
cout<<"NEUES KONTO ANLEGEN\n\n";
cout<<"Konto-Nr.:\t";
cin>>a.kontonummer;
cout<<"\nName:\t";
cin>>a.kontoinhaber;
cout<<"\nEinzahlen:\t";
cin>>a.kontostand;
cout<<"\nKontostand:\t";
cout<<a.kontostand;
_getch();
system("cls");
}
void ausgabeDaten(girokonto a, girokonto b)
{
system("cls");
cout<<"Ihr Kontostand: "<<a.kontostand<<" Euro\n";
}
void einzahlen(girokonto &a, girokonto &b)
{
cout<<"Wieviel einzahlen? ";
cin>>a.einzahlen;
b.kontostand = b.kontostand + a.einzahlen;
system("cls");
}
void auszahlen(girokonto &a, girokonto &b)
{
cout<<"Wieviel wollen Sie ausgezahlt haben?\n\n";
cin>>a.auszahlen;
b.kontostand = b.kontostand - a.auszahlen;
cout<<"Bitte entnehmen Sie Ihre"<<b.kontostand<<" Euro.\n";
cout<<"Jetziger Kontostand: "<<b.kontostand<<" Euro\n";
}
void beratung(girokonto a)
{
cout<<"Wir empfehlen Ihnen wegen Ihren Finanzen ein neues Konto einzurichten.\n";
system("cls");
anlegenKonto(a);
}
void disopoOut(girokonto& a)
{
if(a.kontostand<0) cout<<"\n\nSie sind mit "<<a.kontostand<<" Euro im Minus.\nIhr Dispokredit wurde fuer Sie aktiviert.\n";
}
void kundendatenEingabe(girokonto a)
{
cout<<"Konto-Nr.:\t";
cin>>a.kontonummer;
//cout<<"\nName:\t"; cin>>a.kontoinhaber;
cout<<"\nPIN:\t";
cin>>a.PIN;
if(a.PIN != 1234)
{
cout<<"FALSCHE PIN!";
_getch();
exit(0);
}
system("cls");
}
void speichern(girokonto& a)
{
char KN[10];
char PIN[10];
char KS[100];
itoa(a.kontonummer, KN, 10);
itoa(a.PIN, PIN, 10);
itoa(a.kontostand, KS, 10);
ofstream aus;
aus.open("Bankautomat.txt", ios::out);
aus<<"\n"<<a.kontonummer;
aus<<"\t"<<a.kontoinhaber;
aus<<"\t"<<a.PIN;
aus<<"\t"<<a.kontostand;
aus.close();
ifstream ein;
ein.open("Bankautomat.txt", ios::in);
ein.getline(KN, 250, '\n');
ein.getline(PIN, 250, '\n');
ein.getline(a.kontoinhaber, 250, '\n');
ein.getline(KS, 250, '\n');
ein.close();
cout<<KN<<a.kontoinhaber<<KS;
}
int _tmain(int argc, _TCHAR* argv[])
{
girokonto a;
int tun;
char kunde;
a.kontostand = 0;
cout<<"bereits Kunde?(j/n)";
cin>>kunde;
if(kunde == 'n')
{
system("cls");
anlegenKonto(a);
speichern(a);
system("cls");
do
{
cout<<"\nWas tun?\n";
cout<<"\n1 - Geld abheben";
cout<<"\n2 - Geld einzahlen";
cout<<"\n3 - Kontostand";
cout<<"\n4 - Neues Konto anlegen";
cout<<"\n\n6 - Beenden\n\n";
cin>>tun;
switch(tun)
{
case 1:
auszahlen(a,a);
break;
case 2:
einzahlen(a,a);
break;
case 3:
cout<<a.kontostand<<" Euro";
if(a.kontostand > 50000)
{
beratung(a);
}
break;
case 4:
anlegenKonto(a);
break;
case 5:
exit(0);
break;
}
dispoOut(a);
}
while(kunde = 'j');
}
else
{
kundendatenEingabe(a);
system("cls");
do
{
cout<<"Was tun?\n";
cout<<"\n1 - Geld abheben";
cout<<"\n2 - Geld einzahlen";
cout<<"\n3 - Kontostand";
cout<<"\n4 - Neues Konto anlegen";
cout<<"\n6 - Beenden\n\n";
cin>>tun;
switch(tun)
{
case 1:
auszahlen(a,a);
break;
case 2:
einzahlen(a,a);
break;
case 3:
cout<<a.kontostand<<" Euro";
if(a.kontostand>500000)
{
beratung(a);
}
break;
case 4:
anlegenKonto(a);
break;
case 6:
exit(0);
break;
}
dispoOut(a);
}
while(kunde='j');
}
_getch();
return 0;
}
//waere sehr nett von euch, wenn ihr mir helfen koenntet!!!