dimanche 20 octobre 2019

most of the code doesn't show up only the welcome message and "enter pin"?

Assignment: 1. When you enter an incorrect number of digits( 3 or 5 digits pin number) a message should display “You have entered the incorrect pin number!!...you must enter a four digits pin number.” 2. By showing the message that was display previously the program should allow you to re-enter the correct number of digits. 3. The number of attempts should be three times. 4. When you have entered the correct number of digits a message should display “Your pin has been accepted!!” 5. Each time you enter any amount of pin number it must show in asterisk.

CODE:

#include <iostream>
#include <conio.h> 
//#include <cstdlib.h>
#include <cmath> 

using namespace std; 

int main(){ 
string pass=""; 
int attempts=3;

       cout << "^^^^^^^^^^^^^^^^^^^^^^^^^^^"<< endl;
       cout << "< Welcome to The Bank     >" << endl;
       cout << "<                         >" <<endl;
       cout << "< Please Enter Pin Below  >" << endl;
       cout << " ^^^^^^^^^^^^^^^^^^^^^^^^^^" << endl;

       cout << "\nEnter Pin Number: " << endl;   
       cin >> pass;      

      //attempts= getch();    
       while (attempts <= 3)
         {
        cout << "*";
        getch();
       attempts++; // take this out and it display to infinity
       // }    

      if(pass == "1718")
     {
      cout <<" lOGIN  IN..." << endl <<endl;    
      attempts= -1;
     }

     else{
      cout <<"\nWRONT PIN-TRY AGAIN: " << endl << endl;   
       attempts--;    
     cout << " REMAINING ATTEMPTS: " << attempts << endl << endl;    
     }    

    if (attempts == 0)    
     {
     cout << "Exceed the Pin attempts. Try Later. "<< endl << endl;    
     }   

      if (attempts == -1){

cout << "********************************" << endl;
cout << "*  Welcome to Magali's Bank    *\n";
cout << "*  Select Option:              *\n";
cout << "*    1. Check Balance          *\n";
cout << "*    2. Withdraw               *\n";
cout << "*    3. Deposit                *\n";
cout << "*    4. Exit                   *\n";
cout << "********************************\n";


int balance = 500;
float withdraw;
float deposit;
int user;

cout << "Enter Number: ";
cin >> user;

while (user !=4) {
    switch (user) {

    case 1:
    cout << " Your balance is: " <<balance << endl;
    break;

    case 2:
    cout << "Enter the amount you want withdraw: ";
    cin >> withdraw;
    balance = balance - withdraw;
    break;

    case 3:
    cout << "Enter the amount you want to deposit: ";
    cin >> deposit;
    balance = balance + deposit;
    break;

    default:
    cout << " Need to type 1 for Balance, 2 to Withdraw, 3 to Deposit and 4 to Exit. ";

    }
    cout << "Enter Number: ";
    cin >> user;
     }
    cout << "\nTHANKS FOR USING THE SYSTEM!\n";
     }}

return 0; }

Aucun commentaire:

Enregistrer un commentaire