Step 1: // IntroClasses1.cpp #include using namespace std; class Bank_Acct { pub
ID: 3558970 • Letter: S
Question
Step 1: // IntroClasses1.cpp #include using namespace std; class Bank_Acct { public: Bank_Acct( ); // initialize the state double Check_Balance( ); // return the dollar amount of balance void Deposit(double); // increase balance by a dollar amount void Withdrawal(double); // decrease balance by a dollar amount private: double balance; }; Bank_Acct::Bank_Acct() { balance = 0; } double Bank_Acct::Check_Balance() { return balance; } void Bank_Acct::Deposit(double amount) { balance = balance + amount; } void Bank_Acct::Withdrawal(double amount) { balance = balance - amount; } int main() { Bank_Acct my_Acct; cout << "My account balance = " << my_Acct.Check_Balance() << endl; my_Acct.Deposit(2516.83); // deposit some money into the account cout << "My account balance = " << my_Acct.Check_Balance() << endl; my_Acct.Withdrawal(25.96); // withdraw soome money from the account cout << "My Account Balance = " << my_Acct.Check_Balance() << endl; return 0; } Question 1: Please list any member(s) that make up the state of the class Bank_Acct in the program in Step 1. Question 2: Please list any member(s) that make up the behavior of the class Bank_Acct in the program in Step 1. Question 3: What kind of member function is Check_Balance() in the program in Step 1? NOTE: This question is not asking whether the function is public or private, or whether it is of type double, void, etc. Question 4: What kind of member function is Withdrawal() in the program in Step 1? NOTE: This question is not asking whether the function is public or private, or whether it is of type double, void, etc. Question 5: What kind of member function is Deposit() in the program in Step 1? NOTE: This question is not asking whether the function is public or private, or whether it is of type double, void, etc. Question 6: What kind of member function is Bank_Acct() in the program in Step 1? NOTE: This question is not asking whether the function is public or private, or whether it is of type double, void, etc. Question 7: Describe what the use of the dot operator accomplishes in the program in Step 1. Question 8: Referring to the first cout statement in the program in Step 1, when was the account balance set to 0? What type of member function, if any, accomplishes this?
Explanation / Answer
1)
double balance;
2)
double Check_Balance( );
void Deposit(double);
void Withdrawal(double);
3)
Accessor method.- varies depending on the state of the object
4)
Modifier-changes one or more values of the class
5)
Modifier-changes one or more values of the class
6)
Constructor- called once the object is created.
7)
Code that is executed outside class must be invoked by object reference followed by a dot and field name.
8)
Bank_Acct my_Acct;
This is where an object is created to the class Bank_Acct. When an object is created, the constructor is automatically invoked. In the constructor, the account balance is set to 0.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.