Question

C++ Check Book Program I need to have a checkbook program that uses the following items....

C++ Check Book Program

I need to have a checkbook program that uses the following items. My code that I have appears below.

1) Math operations using built-in math functions

2) Class type in a separate .h file with member functions (accessor functions, get, set, show, display find, etc). There needs to be an overloaded function base/derived classes or a template.

3) Binary File

#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\n";
        cout<<"Enter 1 to withdraw cash\n";
        cout<<"Enter 2 to deposit cash\n";
        cout<<"Enter 3 to transfer from/to savings account\n";
        cout<<"Enter 4 to display the balances\n";
        cout<<"Enter 5 to quit\n";
        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\n";
                    break;
                }
                else
                {
                    checking=checking-amt;
                    cout<<"Cash withdrawl complete\n";
                }
                break;
            case 2:
                while(true)
                {
                    cout<<"Enter the amount you want to deposit :";
                    cin>>amt;
                    if(amt<=0)
                        cout<<"Please enter a valid amount\n";
                    else
                        break;
                }
                checking=checking+amt;
                cout<<"Amount deposit successful\n";
                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\n";
                        else
                            break;
                    }
                    checking=checking-amt;
                    savings=savings+amt;
                    cout<<"Transfer complete\n";
                }
                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\n";
                            break;
                        }
                        else
                        {
                            checking=checking+amt;
                            savings=savings-amt;
                        }
                    }
                    cout<<"Transfer complete\n";
                }
                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;
}

0 0
Add a comment Improve this question Transcribed image text
Answer #1

//header.h

#ifndef FIRST_H_GUARD
#define FIRST_H_GUARD
class Account{
  
double checking,savings;
public:
Account(double camount,double samount);
void checkAmount(double amt);
void depositAmount();
void transfer(char ch);
void showSaving();
void showChecking();
};
#endif

//header.cpp

#include <iostream>
#include<string>
#include "header.h"
using namespace std;
int abc(int a)
{
cout<<a;
return a;
}
Account::Account(double camount,double samount)
{
checking=camount;
savings=samount;
}
void Account::checkAmount(double amt)
{
if(amt>checking)
{
cout<<"You don't have enough balance in the checking account\n";
}
else
{
checking=checking-amt;
cout<<"Cash withdrawl complete\n";
}
}
void Account::depositAmount()
{
double amt;
while(true)
{
cout<<"Enter the amount you want to deposit :";
cin>>amt;
if(amt<=0)
cout<<"Please enter a valid amount\n";
else
break;
}
checking=checking+amt;
cout<<"Amount deposit successful\n";
}
void Account::transfer(char ch)
{
double amt;
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\n";
else
break;
}
checking=checking-amt;
savings=savings+amt;
cout<<"Transfer complete\n";
}
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\n";
  
}
else
{
checking=checking+amt;
savings=savings-amt;
}
}
cout<<"Transfer complete\n";
}
}
void Account::showSaving()
{
cout<<"\n Avalable balance in Saving Account:"<<savings;
}
void Account::showChecking()
{
cout<<"\n Avalable balance in Checking Account:"<<checking;
}

//main.cpp............................

#include <iostream>
#include<string>
#include"header.h"
using namespace std;
class CheckBook:public Account
{
int accountnumber;
string name;
public:
CheckBook(int acc,string s, double s1, double c):Account(s1,c)
{

accountnumber=acc;
name=s;
}
};
int main()
{
double checking,savings;
int acc;
string name;
cout<<"Enter the account number :";
cin>>acc;
cout<<"Enter the name of customer :";
cin>>name;
cout<<"Enter the initial checking account balance :";
cin>>checking;
cout<<"Enter the initial savings account balance :";
cin>>savings;
CheckBook A(acc,name,checking,savings);
double amt;  
while(1)
{
cout<<"Menu\n";
cout<<"Enter 1 to withdraw cash\n";
cout<<"Enter 2 to deposit cash\n";
cout<<"Enter 3 to transfer from/to savings account\n";
cout<<"Enter 4 to display the balances\n";
cout<<"Enter 5 to quit\n";
int choice;
cin>>choice;
switch(choice)
{
case 1:
cout<<"Enter the amount of cash you want to withdraw :";
cin>>amt;
A.checkAmount(amt);
break;
case 2:
A.depositAmount();
break;
case 3:
char ch;
cout<<"Do you want to transfer to the savings account, Y/N :";
cin>>ch;
if(ch=='Y')
{A.transfer(ch);
}
break;
case 4:
A.showSaving();
A.showChecking();
break;
case 5:
return 0;
}
}
return 0;
}

Add a comment
Know the answer?
Add Answer to:
C++ Check Book Program I need to have a checkbook program that uses the following items....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • C++ Banks offer various types of accounts, such as savings, checking, certificate of deposits, and money...

    C++ Banks offer various types of accounts, such as savings, checking, certificate of deposits, and money market, to attract customers as well as meet their specific needs. Two of the most commonly used accounts are savings and checking. Each of these accounts has various options. For example, you may have a savings account that requires no minimum balance but has a lower interest rate. Similarly, you may have a checking account that limits the number of checks you may write....

  • Trying to figure out how to complete my fourth case 4 (option exit), write a function...

    Trying to figure out how to complete my fourth case 4 (option exit), write a function that display a “Good Bye” message and exits/log out from user’s account displaying a menu (sign in, balance, withdraw and exit.. #include<iostream> #include <limits> using namespace std; void printstar(char ch , int n); double balance1; int main() { system("color A0"); cout<<"\n\t\t ========================================="<< endl; cout<<"\t\t || VASQUEZ ATM SERVICES ||"<< endl; cout<<"\t\t ========================================\n\n"<< endl; int password; int pincode ; cout<<" USERS \n"; cout<<" [1] -...

  • C++ programming I need at least three test cases for the program and at least one...

    C++ programming I need at least three test cases for the program and at least one test has to pass #include <iostream> #include <string> #include <cmath> #include <iomanip> using namespace std; void temperatureCoverter(float cel){ float f = ((cel*9.0)/5.0)+32; cout <<cel<<"C is equivalent to "<<round(f)<<"F"<<endl; } void distanceConverter(float km){ float miles = km * 0.6; cout<<km<<" km is equivalent to "<<fixed<<setprecision(2)<<miles<<" miles"<<endl; } void weightConverter(float kg){ float pounds=kg*2.2; cout<<kg<<" kg is equivalent to "<<fixed<<setprecision(1)<<pounds<<" pounds"<<endl; } int main() { string country;...

  • I am trying to run this program in Visual Studio 2017. I keep getting this build...

    I am trying to run this program in Visual Studio 2017. I keep getting this build error: error MSB8036: The Windows SDK version 8.1 was not found. Install the required version of Windows SDK or change the SDK version in the project property pages or by right-clicking the solution and selecting "Retarget solution". 1>Done building project "ConsoleApplication2.vcxproj" -- FAILED. #include <iostream> #include<cstdlib> #include<fstream> #include<string> using namespace std; void showChoices() { cout << "\nMAIN MENU" << endl; cout << "1: Addition...

  • I need help in my C++ code regarding outputting the enums in string chars. I created...

    I need help in my C++ code regarding outputting the enums in string chars. I created a switch statement for the enums in order to output words instead of their respective enumerated values, but an error came up regarding a "cout" operator on my "Type of Item" line in my ranged-based for loop near the bottom of the code. I tried casting "i.type" to both "i.GroceryItem::Section::type" and "i.Section::type", but neither worked. Simply put, if a user inputs 1 as their...

  • C++

    /*Colesha PearmanCIS247CATM ApplicationMay 4,2020*///Bring in our libaries#include"stdafx.h" #include<iostream>#include<conio.h>#include<string>#include<fstream>//read/write to files#include<ctime>//time(0)#include<iomanip>//setpresision stdusing namespace std; //create constant vaules-- cannot be changedconst int EXIT_VALUE = 5;const float DAILY_LIMIT = 400.0f;const string FILENAME = "Account.txt"; //create balance variabledouble balance = 0.0; //prototypesvoid deposit(double* ptrBalance);void withdrawal(double* ptrBalance, float dailyLimit);  //overloaded method-this verision does not take withdrawal amount void withdrawal(double* ptrBalance, float dailyLimit, float amount);  //overloaded method that takes withdrawal amount ///Enrty point to the application int main(){                 //look for the starting balance; otherwise generate a random balance                 ifstream...

  • I need help modifying this code please ASAP using C++ Here is what I missed on this code below Here are the instruction...

    I need help modifying this code please ASAP using C++ Here is what I missed on this code below Here are the instructions Here is the code Produce correct70 pts O pts Full Marks No Marks results and statisfy requirements view longer Comments 1. Your display amount is not readable 2. I withdraw more than my balance, but I didn't see any error message description Documentations10 pts 0 pts Full Marks No Marks : comment i code and block comment...

  • This is for a C++ program: I'm almost done with this program, I just need to...

    This is for a C++ program: I'm almost done with this program, I just need to implement a bool function that will ask the user if they want to repeat the read_course function. I can't seem to get it right, the instructions suggest a do.. while loop in the main function. here is my code #include <iostream> #include <cstring> #include <cctype> using namespace std; const int SIZE = 100; void read_name(char first[], char last[]); void read_course(int & crn, char des[],...

  • #include <iostream> #include <conio.h> #include<limits> using namespace std; int main(){ char oparand, ch = 'Y'; int...

    #include <iostream> #include <conio.h> #include<limits> using namespace std; int main(){ char oparand, ch = 'Y'; int num1, num2, result; while(ch == 'Y'){ cout << "Enter first number: "; cin >> num1; while(1){//for handling invalid inputs if(cin.fail()){ cin.clear();//reseting the buffer cin.ignore(numeric_limits<streamsize>::max(),'\n');//empty the buffer cout<<"You have entered wrong input"<<endl; cout << "Enter first number: "; cin >> num1; } if(!cin.fail()) break; } cout << "Enter second number: "; cin >> num2; while(1){ if(cin.fail()){ cin.clear(); cin.ignore(numeric_limits<streamsize>::max(),'\n'); cout<<"You have entered wrong input"<<endl; cout <<...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT