Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ as simple as possible. 1. // P61a.cpp - This program creates uses a structure for loan, initialize it from the ke yboard, then displays

C++ as simple as possible.

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

1. // P61a.cpp - This program creates uses a structure for loan, initialize it from the ke yboard, then displays the struct 2. 3. include 4. include 5. using namespace std; 6. 7. struct Loan // Loan is called structure tag 8. { 9. int ID; // assume an unique integer between 1111-9999 float amount; // $ amount of the loan 11. float rate; // annual interest rate 12. int term; // number of months, length of the loan 13. }; 14. 15. float payment(Loan 1); 10. 16. 31. 17. int main() 18. 19. Loan loanl; 2e. float monthly payment; 21. 22 // Initialize the loani structure 23. cout > loani. ID; 25. 26. cout > loani. amount; 28. 29. cout > loani.rate; 32 cout > loani. term; 34 35. monthly payment = payment(loan); 36. 37. cout 3. using namespace std; 5. class Loan // Loan is called structure tag 6. { 7. public: 8. void set(); 9. float payment(); 10. void display(); 11. private: 12. int ID; // assume an unique integer between 1111-9999 13. float amount; // $ amount of the loan 14. float rate; // annual interest rate 15. int term; // number of months, length of the loan 16. }; 17. 18. int main() 19. 22. 20. Loan loani; 21. loan1.set(); 23. 24. return; 25.) 26. 27. void Loan::set() 28. 29. // Initialize the loani object 30. cout > ID; 32. 33 cout > aliount; 35. 36. cout > rate; 38. 39. cout > tera; 41. } Exercise 6.2 - 6.3 Complete program P62a.cpp by defining the member functions display and payment for class Loan. Note that the display function will display all the information about a loan, for example: Loan ID: Loan Amount: Loan Rate: Loan Term: Modify the class Loan and include the monthly payment as a data member in that class. Note that you still have the payment function that computes the payment. Since you include the monthly payment as a member, instead of returning a value from the function, you directly set the value for monthly payment in that function. Also, add a new function called add loans, defined as: 11. float add_loans (Loan loan1, Loan loan2); The new function, add_loans, takes two loan objects and computes the total monthly payment, i.e., the sum of monthly payments of the two loans

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

What does the start( ) method defined by Thread do?

Answered: 1 week ago