#include %26lt;iostream%26gt;
#include %26lt;istream%26gt;
using namespace std;
class CDAccount
{
double balance;
double interest_rest;
int term; //months until maturity
};
void get_data (CDAccount%26amp; the_account);
int main()
{
CDAccount account;
get_data(account);
double rate_fraction, interest;
rate_fraction = account.interest_rest/100.0;
interest = account.balance*rate_fraction*(account.t...
account.balance = account.balance + interest;
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(2);
cout %26lt;%26lt; "When your CD matures in "
%26lt;%26lt; account.term %26lt;%26lt; "months,\n"
%26lt;%26lt; account.balance %26lt;%26lt; endl;
return 0;
}
void get_data(CDAccount%26amp; the_account)
{
cout %26lt;%26lt; "Enter account balance: $";
cin %26gt;%26gt; the_account.balance;
cout %26lt;%26lt; "Enter account interest rate: ";
cin %26gt;%26gt; the_account.interest_rest;
cout %26lt;%26lt; "Enter the number of months until maturity\n"
%26lt;%26lt; "(must be 12 or fewer months): ";
cin %26gt;%26gt; the_account.term;
}
Help with C++. how do i redefine the code below making it a class that has private function and variables?
Move the 'get_data' function to within the braces of the class. Since it's inline, you don't need the function prototype definition.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment