#include<bits/stdc++.h>
using namespace std;
class Customer
{
string name;
int balance,account_number;
public:
Customer(string name,int balance,int account_number)
{
this->name=name;
this->balance=balance;
this->account_number=account_number;
}
void deposit(int amount)
{
if(amount>0)
{
balance=balance+amount;
cout<<amount<<" rs is credited successfully\n";
}
else
{
throw runtime_error("Enter valid amount");
}
}
void withdraw (int amount)
{
if(amount>0 && amount<=balance)
{
balance=balance-amount;
cout<<amount<<" rs is debited successfully\n";
}
else if(amount>balance)
{
throw runtime_error("Your balance is low");
}
else
{
throw ("Enter valid amount");
}
}
};
int main()
{
try
{
Customer C1("Rohit",5000,10);
C1.withdraw(6000);
}
catch(const runtime_error &e)
{
cout<<"Exception occured: "<<e.what()<<endl;
}
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKY2xhc3MgQ3VzdG9tZXIKCXsKCQlzdHJpbmcgbmFtZTsKCQlpbnQgYmFsYW5jZSxhY2NvdW50X251bWJlcjsKCQkKCQlwdWJsaWM6CgkJCUN1c3RvbWVyKHN0cmluZyBuYW1lLGludCBiYWxhbmNlLGludCBhY2NvdW50X251bWJlcikKCQkJewoJCQkJdGhpcy0+bmFtZT1uYW1lOwoJCQkJdGhpcy0+YmFsYW5jZT1iYWxhbmNlOwoJCQkJdGhpcy0+YWNjb3VudF9udW1iZXI9YWNjb3VudF9udW1iZXI7CgkJCX0KCQkJCgkJCXZvaWQgZGVwb3NpdChpbnQgYW1vdW50KQoJCQl7CgkJCQlpZihhbW91bnQ+MCkKCQkJCXsKCQkJCQliYWxhbmNlPWJhbGFuY2UrYW1vdW50OwoJCQkJCWNvdXQ8PGFtb3VudDw8IiBycyBpcyBjcmVkaXRlZCBzdWNjZXNzZnVsbHlcbiI7CgkJCQl9CgkJCQllbHNlCgkJCQl7CgkJCQkJdGhyb3cgcnVudGltZV9lcnJvcigiRW50ZXIgdmFsaWQgYW1vdW50Iik7CgkJCQl9CgkJCX0KCQkJCgkJCXZvaW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