Brauche Hilfe bei meinem Programm, das will nich wies soll



  • Ich moechte Passwort eingeben...solange das falsch is soll er immer passwort abfragen,...wenns dann richtig is, soll er eifnach weiter machen...

    // PROJEKT BANK
    #include "stdafx.h"
    #include <iostream>
    #include <fstream>
    #include <conio.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <time.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);
    void einzahlen(girokonto&, girokonto&);
    void auszahlen(girokonto&, girokonto&);
    void beratung(girokonto);
    void dispoOut(girokonto&);
    void kundendatenEingabe(girokonto&);
    //void kontouebersicht();
    void speichern(girokonto&);
    
    void anlegenKonto(girokonto &a)
    {
    	srand(time(NULL));
    	a.PIN = rand ();
    
    	cout<<"NEUES KONTO ANLEGEN\n\n";
    	cout<<"Konto-Nr.:\t";			cin>>a.kontonummer;
    	cout<<"\nName:\t\t";			cin>>a.kontoinhaber;
    	cout<<"\nEinzahlen:\t";			cin>>a.kontostand;
    	//cout<<"\nKontostand:\t";		cout<<a.kontostand<<" Euro";
    
    	cout<<"\n\nPIN wird generiert...";      cout<<"\n\nneue PIN:\t"<<a.PIN;
    
    	_getch();
    	system("cls");
    }
    
    void ausgabeDaten(girokonto a)
    {
    	cout<<"Ihr Kontostand: "<<a.kontostand<<" Euro\n";
    }
    
    void einzahlen(girokonto &a, girokonto &b)
    {
    	system("cls");
    	cout<<"Wieviel einzahlen? ";	cin>>a.einzahlen;
    
    	b.kontostand = b.kontostand + a.einzahlen;
    	//system("cls");
    }
    
    void auszahlen(girokonto &a, girokonto &b)
    {
    	system("cls");
    	cout<<"PIN: ";	cin>>a.PIN;
    	//for(rand()=0;rand()!=a.PIN;rand()++)	cin>>a.PIN;
    	if(rand()!=a.PIN)
    	{
    		do
    		{
    			if(rand()!=a.PIN)	cout<<"FALSCHE EINGABE";
    		}
    		while(rand()!=a.PIN);	
    	}
    	cout<<"Wieviel wollen Sie ausgezahlt haben?\n\n";	
    	cout<<"\n10\t20\t50\n100\t200\n\n";
    	cin>>a.auszahlen;
    	if(a.auszahlen != 10||20||50||100||200)	cout<<"Falsche Eingabe!";
    	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)
    {
    	system("cls");
    	cout<<"Wir empfehlen Ihnen wegen Ihren Finanzen ein neues Konto einzurichten.\n";
    	system("cls");
    	anlegenKonto(a);
    }
    
    void dispoOut(girokonto& a)
    {
    	system("cls");
    	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)
    {
    	system("cls");
    	cout<<"Konto-Nr.:\t";	cin>>a.kontonummer;
    	//cout<<"\nName:\t";	cin>>a.kontoinhaber;
    	cout<<"\nPIN:\t\t";	cin>>a.PIN;
    /////////////////////////////////////////////////*Passwortabfrage*////////////////////////////////////////////////////////
    //evtl. mit do while,...solange pw falsch gehts nicht weiter...
    	/*if(a.PIN != rand())
    	{
    		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<<"\n\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<<"\nWas 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;
    }
    //Bin ueber jede Hilfe dankbar!!!
    




  • Ich habe den Code nicht ganz gelesen, weil er mir zu lang ist, aber warum in aller welt prüfst du in Zeile 113 auf eine rand() Funktion? die gibt eine random-Zahl aus. Bist du sicher, dass du das willst?

    gruß
    syntax


Anmelden zum Antworten