The purpose of this assignment is to show you how the file and exception throwing/handling operations...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
The purpose of this assignment is to show you how the file and exception throwing/handling operations take place in C++. Write a BankAccount class which has the following functions and member variables in it. Member Functions: • A constructor which initializes all member variables with the given parameters, • a virtual save function (returns nothing and takes nothing), Save funtion creates a binary file which includes the concatenated values of all member variables of the current instance of the class. However, you should not create it by hand. All writing operations should be taken care by the write function of the fstream base class. As an example method, suppose you have a struct with member variables same as the BankAccount class. Then, you should call the write function such as: account_file.write((const char*) &var_struct, sizeof(VarStruct)); When you check the file contents, you shouldn't be able to read it except for the raw strings. O a virtual load function with a parameter of a string (file name) and returns nothing, ▪ Load function is almost similar to the save function. It takes a file name as parameter. Then, opens the file as a binary file, reads content of the file to the memory. You can use the same method in the save function. For example: account_file.read ((char*) &var_struct, sizeof (VarStruct)); Here, the var_struct variable contains all the loaded values for the BankAccount class. O a draw function which takes a float amount and returns a float, ■ Draw, if any, draws the specified amount of money from the account and returns the amount. If there is not enough money, it throws an Insufficient Deposit exception. You can define an empty class for this exception. There is nothing special about it. an apply_interest function (returns nothing and takes nothing), ■ When called, this function applies the specified interest rate to the principal (the deposit). However, with different subclasses the effect of this function may vary. O a constant virtual report function (returns nothing and takes nothing). ▪ The report function just prints a small report for the bank account which it is a member. Member Variables: • Integer account_id, string name, float deposit, float interest rate (protected) Write 2 more classes PersonalBankAccount and BusinessBankAccount. Both inherits the BankAccount class. While initializing PersonalBankAccount class, change the interest rate to 18% and while initializing BusinessBankAccount class, change the interest rate to 6.5%. For the report function, you should just add one more line to it to show the type of the bank account. You can find an example of it in the sample run. In the main function, create 2 PersonalBankAccount and 1 BusinessBankAccount. Save them to their individual binary files. Then, load the second file to the first defined personal bank account and vice versa (in otherwords, swap the contents of them). Finally, draw excess amount of money from the BusinessBankAccount and write reports for all of the bank accounts. . Sample Run: =========Before swapping accounts== TYPE: PERSONAL Account ID: 5421 Account Name: PersonalAcc1 Deposit: 8000 Interest Rate: 18% TYPE: PERSONAL Account ID: 1234 Account Name: PersonalAcc2 Deposit: 5856 2 Interest Rate: 18% =========After swapping accounts== TYPE: PERSONAL Account ID: 1234 Account Name: PersonalAcc2 Deposit: 5856 Interest Rate: 18% TYPE: PERSONAL Account ID: 5421 Account Name: PersonalAcc1 Deposit: 8000 Interest Rate: 18% Insufficient Deposit exception catched. TYPE: BUSINESS Account ID: 5555 Account Name: BusinessAcc Deposit: 70000 Interest Rate: 6.5% The purpose of this assignment is to show you how the file and exception throwing/handling operations take place in C++. Write a BankAccount class which has the following functions and member variables in it. Member Functions: • A constructor which initializes all member variables with the given parameters, • a virtual save function (returns nothing and takes nothing), Save funtion creates a binary file which includes the concatenated values of all member variables of the current instance of the class. However, you should not create it by hand. All writing operations should be taken care by the write function of the fstream base class. As an example method, suppose you have a struct with member variables same as the BankAccount class. Then, you should call the write function such as: account_file.write((const char*) &var_struct, sizeof(VarStruct)); When you check the file contents, you shouldn't be able to read it except for the raw strings. O a virtual load function with a parameter of a string (file name) and returns nothing, ▪ Load function is almost similar to the save function. It takes a file name as parameter. Then, opens the file as a binary file, reads content of the file to the memory. You can use the same method in the save function. For example: account_file.read ((char*) &var_struct, sizeof (VarStruct)); Here, the var_struct variable contains all the loaded values for the BankAccount class. O a draw function which takes a float amount and returns a float, ■ Draw, if any, draws the specified amount of money from the account and returns the amount. If there is not enough money, it throws an Insufficient Deposit exception. You can define an empty class for this exception. There is nothing special about it. an apply_interest function (returns nothing and takes nothing), ■ When called, this function applies the specified interest rate to the principal (the deposit). However, with different subclasses the effect of this function may vary. O a constant virtual report function (returns nothing and takes nothing). ▪ The report function just prints a small report for the bank account which it is a member. Member Variables: • Integer account_id, string name, float deposit, float interest rate (protected) Write 2 more classes PersonalBankAccount and BusinessBankAccount. Both inherits the BankAccount class. While initializing PersonalBankAccount class, change the interest rate to 18% and while initializing BusinessBankAccount class, change the interest rate to 6.5%. For the report function, you should just add one more line to it to show the type of the bank account. You can find an example of it in the sample run. In the main function, create 2 PersonalBankAccount and 1 BusinessBankAccount. Save them to their individual binary files. Then, load the second file to the first defined personal bank account and vice versa (in otherwords, swap the contents of them). Finally, draw excess amount of money from the BusinessBankAccount and write reports for all of the bank accounts. . Sample Run: =========Before swapping accounts== TYPE: PERSONAL Account ID: 5421 Account Name: PersonalAcc1 Deposit: 8000 Interest Rate: 18% TYPE: PERSONAL Account ID: 1234 Account Name: PersonalAcc2 Deposit: 5856 2 Interest Rate: 18% =========After swapping accounts== TYPE: PERSONAL Account ID: 1234 Account Name: PersonalAcc2 Deposit: 5856 Interest Rate: 18% TYPE: PERSONAL Account ID: 5421 Account Name: PersonalAcc1 Deposit: 8000 Interest Rate: 18% Insufficient Deposit exception catched. TYPE: BUSINESS Account ID: 5555 Account Name: BusinessAcc Deposit: 70000 Interest Rate: 6.5%
Expert Answer:
Answer rating: 100% (QA)
Below is the C program include using namespace std exception class for insuffici... View the full answer
Related Book For
Concepts In Federal Taxation
ISBN: 9780324379556
19th Edition
Authors: Kevin E. Murphy, Mark Higgins, Tonya K. Flesher
Posted Date:
Students also viewed these marketing questions
-
For the discussion: To whom should the CPA be ultimately responsible? Why? Based on the article, what do you think are the most powerful reasons auditors struggle to be truly objective and...
-
The purpose of this assignment is to demonstrate your ability to evaluate one quantitative or qualitative nursing research article of interest from any refereed nursing journal. Writing a critical...
-
Purpose of Assignment The purpose of this assignment is to help students gain a better understanding of the financial statements used for corporate financial reporting and the key ratios used to make...
-
a) Discuss the effect of solvent polarity on Rf-values. b)Explain how the Rf (Retention Factor)-values can be in agreement or disagreement with the like dissolves like principle?
-
Cone Corporation is in the process of preparing its December 31, 2011, balance sheet. There are some questions as to the proper classification of the following items: a. $50,000 in cash set aside in...
-
Listed below are several terms and phrases associated with pensions. Pair each item from List A with the item from List B (by letter) that is most appropriately associated with it. List A List B 1....
-
Barium sulfide is produced by reacting barium sulfate ore with coal. The result is barium black ash, which is \(\mathrm{BaS}\) plus insoluble solids. Since \(\mathrm{BaS}\) is soluble in water, it...
-
At a time when demand for ready-to-eat cereal was stagnant, a spokesperson for the cereal maker Kelloggs was quoted as saying, . . . for the past several years, our individual company growth has...
-
Kara, Incorporated, imposes a payback cutoff of three years for its international investment projects. Assume the company has the following two projects available. Year Cash Flow (A) Cash Flow (B) 0...
-
(Allocating Parking Spots) You are the manager of a luxury apartment building whose parking garage contains 300 parking spots. Residents may choose to purchase a dedicated parking spot for $60,000...
-
An all equity company's cost of capital is 13.4 per cent and its value is $38 million. The company is paying 37 per cent tax. The company takes debt to reduce ordinary shares to have debt equity...
-
In this assignment, I would like you to start your essay by writing the thesis paragraph and two paragraphs supporting that thesis with a close-reading of the short story you are working with. Your...
-
Beam ABC shown in Figure 1 is 4m long. Support at A is fixed and support at B is a roller. C is free. A 15kN force acts downward as shown in Figure 1. El is constant. (a) Determine the deflected...
-
Question 4 of 5 View Policies Show Attempt History Current Attempt in Progress Selected accounts for Kingbird, Inc., a private company following ASPE, as at December 31, 2023, are as follows...
-
a)The Universal Commercial Laws hold Merchants to higher standards than a non-merchant. Since Nina and Seth are both merchants, the Merchant exception applies to this situation. Merchant exception...
-
3. Consider the railgun system below. The bar has width w, mass m, and current lo provided by the DC current source, and starts at rest at y = 0. There is an external magnetic field B, and the rails...
-
Garnet, Inc., has a target debt-equity ratio of 0.49. Its WACC is 11.9%, and the tax rate is 39% If you know that the after-tax cost of debt is 6.5%, what is the cost of equity? (Report answer in...
-
2.) Find the Laplace transform of f(t) 7e-St cos 2t +9 sinh2 2t. Use Laplace Table. %3D
-
Oliver Company obtains a patent by paying $15,000 on June 21 of this year. Identify the tax issue(s) posed by the facts presented. Determine the possible tax consequences of each issue that you...
-
What is the difference between a property's use and its type?
-
EndLand Company reports the following results for the current year: Gross profit from sales ................ $350,000 Dividends received (less than 20% ownership) ........ 40,000 Long-term capital...
-
Presented below are summary financial data from the General Electric Company 2015 annual report. Using the ratio definitions from Exhibit 4.6, calculate the following liquidity and solvency ratios:...
-
Presented below are summary financial data from the The Coca-Cola Company 2015 annual report. Using the ratio definitions from Exhibit 4.6, calculate the following liquidity and solvency ratios: cash...
-
Presented below are summary financial data from The Boeing Company 2015 annual report. Using the ratio definitions from Exhibit 4.6, calculate the following liquidity and solvency ratios: cash and...
Study smarter with the SolutionInn App