can someone help me solve my problem in C++ ( ATM)

0 jennel celiz · January 4, 2015
Im not good in english so please bare with me. THANKS

Hi guys, i already created a not so perfect and ideal ATM program in C++
its running okay but i have some major problem i can't figure out.

MY PROBLEM IS :  I want to create a ATM that can only withdraw hundred of amount OR a  thousand with hundred.
                                    example. i have 10,000 in my savings. and i want the ATM to only withdraw
                                    with 100,200,300,400,500,600,700,800,900,1000,1100,1200 and so on...

this is what i got at the moment. THANKS IN ADVANCE !
------>>>


#include <iostream>
using namespace std;

int balance = 10000;
int total;
int amount;
int choice;


int main(){

    cout << "Welcome To Simple ATM\n" <<endl;
    cout << "Please Select Transaction" <<endl;
    cout << "Select 1 or 2 "<< endl;
    cout << "1. Balance Inquiry" <<endl;
    cout << "2. Withdraw" <<endl;
    cin >> choice;


if (choice==1)
   {
    cout << "Your Total Balance is: " << balance <<endl;
   }


if (choice==2)
    {
    cout << "Please input the amount you want to withdraw" <<endl;
    cin >> amount;

     if(amount>balance)
       {
        cout << "Insufficient Amount" <<endl;
       }

     if (amount<1)
       {
        cout << " INVALID AMOUNT " << endl;
       }

    if(amount<=balance)
    {
    total = balance - amount;
    cout << "Your total balance is: " << total <<endl;
    }

    }


if (choice>2)
    {
    cout << "TRY AGAIN \n" <<endl;
    return main();
    }

if (choice<1){
    cout << "Try AGAIN \n" <<endl;
    return main();
}
}


Post a Reply

Replies

Oldest  Newest  Rating
0 Laura Lee · January 4, 2015
You can check if the amount they enter is divisible by 100 with a remainder of zero.
The modulus is perfect for this.
if( (amount%100) != 0)
{
cout << "Invalid amount!";
}
  • 1

C++

107,207 followers
About

Used in many types of software including music players, video games, and many large scale applications.

Links
Moderators
Bucky Roberts Administrator