Program to perform deposit/withdraw and other functions of a bank.

This program will take the input from user and withdraw/deposit the amount as per the liking of the user.

 

Code:

 

#include<iostream>
#include<math.h>
#include<strings.h>
using namespace std;
class bank
{
    char n[100];
    char actp[100];
    int accn;
    int bal;
    int dep;
    int wit;
public:
    void getdata();
    void display();
    void withdraw();
    void deposit();
};

int main()
{
    int a,balance=12555;
    bank b1;
    cout<<"Hello! Please choose an option from the menu"<<endl<<"1. Deposit"<<endl<<"2. Withdraw"<<endl<<"3. Balance Inquiry"<<endl<<"4. Your info."<<endl;
    cin>>a;
    switch(a)
    {
    case 1:
        {
            b1.deposit();
            break;
        }
    case 2:
        {
            b1.withdraw();
            break;
        }
    case 3:
        {
            cout<<"Your current balance is "<<balance;
            break;
        }

    case 4:
        {
            b1.getdata();
            b1.display();
            break;
        }
    default:
        {
            cout<<"You have entered an invalid option! Please try again later..";
        }
    }
}
void bank::getdata()
{
    strcpy(n,"Shubham");
    strcpy(actp,"Saving");
    accn=001452;
    bal=12555;
}

void bank::display()
{
    cout<<"Your name is "<<n<<endl<<"Your Account type is "<<actp<<endl<<"Your Account Number is "<<accn<<endl<<"Your Current Balance is "<<bal;

}

void bank::deposit()
{
    accn=001452;
    bal=12555;
    cout<<"Enter the amount you want to deposit in your account."<<endl;
    cin>>dep;
    cout<<"Your current balance is "<<dep+bal<<" now!"<<endl;

}
void bank::withdraw()
{
    accn=001452;
    bal=12555;
    cout<<"Enter the amount you want to withdraw from your account."<<endl;
    cin>>wit;
    if(bal-wit<2000)
    cout<<"Your current balance is "<<bal<<" and no balance has been withdrawn since you need to maintain minimum 2000 balance."<<endl;
    else
        cout<<"Your current balance is "<<bal-wit<<"!";

}

 

Program to find the number repeating maximum using classes

This is a program to find the number out of the given list of numbers which repeats the maximum no. of times.

We have predefined the numbers using array.

 

Code:

#include<iostream>
#include<math.h>
using namespace std;
int main()
{
    int arr1[]={3,3,3,1,5,6,7};
    int arr2[7];
    int i,j,k=0,l=0;
    for(i=0;i<8;i++)
    {
        arr2[i-1]=k;
        k=0;

        for(j=0;j<8;j++)
        {
            if(arr1[i]==arr1[j])
            {
                k++;
            }

        }
    }
    for(i=0;i<7;i++)
    {
    cout<<arr1[i]<<" has repeated "<<arr2[i]<<" times."<<endl;
    }
    cout<<endl<<"The maximum repeats are shown below:"<<endl;

    for(i=0;i<8;i++)
    {
        if(l>1)
        {
            cout<<arr1[i-1]<<" has repeated "<<arr2[i-1]<<" times."<<endl;
            l=0;
        }
        for(j=0;j<8;j++)
        {
            if(arr2[i]>arr2[j])
            {
                l++;
            }
        }
    }
}