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?
-
Popley Manufacturing had a 1.40 operating leverage factor when sales were $ 60,000. Popley Manufacturings contribution margin ratio was 35%. What were the companys fixed expenses?
-
The proponents of social responsibility claim that the arguments against responsibility are flawed. Study those arguments and explain how each might be flawed. Give details to support your claim.
-
Derive the stiffness and mass matrices of a uniform beam element in transverse vibration rotating at an angular velocity of \(\Omega \mathrm{rad} / \mathrm{s}\) about a vertical axis as shown in Fig....
-
At the beginning of June, Veneskey Printing Company budgeted 19,200 books to be printed in June at standard direct materials and direct labor costs as follows: Direct materials ....... $ 36,000...
-
The Larisa Company buys machinery on April 1, Year One, for $40,000 with an expected life of ten years and residual value of $10,000. The double-declining balance method is applied along with the...
-
Ricky Bobby is divorced with two dependent children, ages 9 and 11. During 2022, Ricky had the following gross receipts: Salary income Passive loss from Alpha Partnership (Ricky is a limited partner...
-
Joe agreed on April 1 to sell and deliver 1,000 bushels of wheat to a grain elevator on June 1 for $10 per bushel. He then refused to deliver on June 1 because the market price was then $15 per...
-
Analyze the "National Models of Healthcare Delivery". Develop your ideal model for healthcare delivery in the United States.
-
Conduct a General Market Potential (covering market size, market growth, and quality of demand) and Site Potential of the chosen country.
-
Sales of personal care products tend to remain stable during recessionary periods. Classify the industry sector of personal care products.
-
Sheridan Construction Company has entered into a contract beginning January 1, 2025, to build a parking complex. It has been estimated that the complex will cost $596,000 and will take 3 years to...
-
Discuss emerging trends and advancements in IPC research, such as lock-free synchronization mechanisms, zero-copy data transfers, and techniques for minimizing latency in inter-process communication .
-
How would you explain the relationship between DNA replication, telomerase activity, and aging and cell death. Given that the genomes of all organisms are made up of As, Ts, Cs, and Gs, how does one...
-
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...
-
You have been asked to join the hospitals task force for developing a plan to increase the organizations workforce diversity from its current 20% level to 40% over the next 5 years. How does your...
-
Visit the Hofstede Centre (https://geerthofstede.com/culture-geerthofstede- gert-jan-hofstede/6d-model-of-nationalculture/) and review the scores by country for the various cultural dimensions that...
-
With diverse patient populations come language translation issues. Medical interpretation is a challenge facing most health organizations. Medical interpretation and translation services are costly....
Study smarter with the SolutionInn App