Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

c++ programming - Checkbook Write a C++ program to perform the basic operations

ID: 656997 • Letter: C

Question

c++ programming - Checkbook
Write a C++ program to perform the basic operations of the checkbook. There will be only four types of transactions as follows:
? - cash withdrawals
? - deposits
? - transfer from/to the savings account
? - display the balances
The information needed for each transaction is a bit different, so you will need to prompt the user based on the transaction type. Use a switch statement.
Also, remember to validate the data before you use it. For example, one cannot deposit a negative amount of money into his/her account. One can not withdraw more cash than he/she has available. Please keep track of one

Explanation / Answer

#include <iostream>
using namespace std;
int main()
{
    double checking,savings;
    cout<<"Enter the initial checking account balance :";
    cin>>checking;
    cout<<"Enter the initial savings account balance :";
    cin>>savings;
    double amt;  
    while(1)
    {
        cout<<"Menu ";
        cout<<"Enter 1 to withdraw cash ";
        cout<<"Enter 2 to deposit cash ";
        cout<<"Enter 3 to transfer from/to savings account ";
        cout<<"Enter 4 to display the balances ";
        cout<<"Enter 5 to quit ";
        int choice;
        cin>>choice;
        switch(choice)
        {
            case 1:
                cout<<"Enter the amount of cash you want to withdraw :";
                cin>>amt;
                if(amt>checking)
                {
                    cout<<"You don't have enough balance in the checking account ";
                    break;
                }
                else
                {
                    checking=checking-amt;
                    cout<<"Cash withdrawl complete ";
                }
                break;
            case 2:
                while(true)
                {
                    cout<<"Enter the amount you want to deposit :";
                    cin>>amt;
                    if(amt<=0)
                        cout<<"Please enter a valid amount ";
                    else
                        break;
                }
                checking=checking+amt;
                cout<<"Amount deposit successful ";
                break;
            case 3:
                char ch;
                cout<<"Do you want to transfer to the savings account, Y/N :";
                cin>>ch;
                if(ch=='Y')
                {
                    while(true)
                    {
                        cout<<"Enter the amount you want to transfer to the savings account:";
                        cin>>amt;
                        if(amt<=0 and amt<checking)
                            cout<<"Please enter a valid amount ";
                        else
                            break;
                    }
                    checking=checking-amt;
                    savings=savings+amt;
                    cout<<"Transfer complete ";
                }
                else
                {
                    cout<<"Do you want to transfer from the deposit account, Y/N :" ;
                    cin>>ch;
                    if(ch=='Y')
                    {
                        cout<<"Enter the amount of cash you want to transfer from the savings account :";
                        cin>>amt;
                        if(amt>savings)
                        {
                            cout<<"You don't have enough balance ";
                            break;
                        }
                        else
                        {
                            checking=checking+amt;
                            savings=savings-amt;
                        }
                    }
                    cout<<"Transfer complete ";
                }
                break;
            case 4:
                cout<<"Your current savings account balance :$"<<savings<<endl;
                cout<<"Your current checking account balance :$"<<checking<<endl;
                break;
            case 5:
                return 0;
        }
    }
    return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at drjack9650@gmail.com
Chat Now And Get Quote