Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Pre-Lab Redefine CDAccount from Display 10.1 to be a class rather than structure. Use the same member variables as in Display 10.1 but make them
Pre-Lab Redefine CDAccount from Display 10.1 to be a class rather than structure. Use the same member variables as in Display 10.1 but make them private. Include member functions for each of the following: to return initial balance to return balance at maturity to return interest rate to return the term default constructor . * constructor to set all the member variables to any specified values input function (istream&) * output function (ostream&) Embed your class definition in a test program. Sample output: CD Account interest rate: 10 CD Account initial balance: 100 CD Account balance at maturity is: 105 CD Account term is: 6 months when your CD matures in 6 months it will have a balance of 185.00 Enter CD initial balance, interest rate, and term: 200 1e 12 CD Account interest rate: 10.00 CD Account initial balance: 280.00 CD Account balance at maturity is: 220.e0 CD Account term is: 12 months when your CD matures in 12 months it will have a balance of 220.00 1 E//DISPLAY 10.1 A Structure Definition 2 //Program to demonstrate the CDAccount structure type. #include iostream using namespace std; 6 //structure for a bank certificate of deposit: 8 struct CDAccount 9 double balance; double interestRate int term;//months until maturity 12 13 15 16 17 void getData(CDAccount& theAccount); E//Postcondition: theAccount.balance and theAccount.interestRate //have been given values that the user entered at the keyboard 19 20 21 Eint main() 23 24 25 26 27 CDAccount account: getData(account); double rateFraction, interest rateFractionaccount.interestRate / 100.0; interestaccount.balance*rateFraction (account.term 12.0); account.balanceaccount.balance interest; 29 30 31 cout.setf(ios::fixed); cout.setf(ios: :showpoint); cout.precision(2); cout theAccount.balance; cout theAccount.interestRate; cout
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started