Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please help me do this! //DISPLAY 10.1 A Structure Definition //Program to demon

ID: 3758077 • Letter: P

Question

Please help me do this!

//DISPLAY 10.1 A Structure Definition

//Program to demonstrate the CDAccount structure type.

#include <iostream>

using namespace std;

//Structure for a bank certificate of deposit:

struct CDAccount

{

    double balance;

    double interest_rate;

    int term;//months until maturity

};

void get_data(CDAccount& the_account);

//Postcondition: the_account.balance and the_account.interest_rate

//have been given values that the user entered at the keyboard.

int main( )

{

    CDAccount account;

    get_data(account);

    double rate_fraction, interest;

    rate_fraction = account.interest_rate/100.0;

    interest = account.balance*rate_fraction*(account.term/12.0);

    account.balance = account.balance + interest;

    cout.setf(ios::fixed);

    cout.setf(ios::showpoint);

    cout.precision(2);

    cout << "When your CD matures in "

         << account.term << " months, "

         << "it will have a balance of $"

         << account.balance << endl;

    return 0;

}

//Uses iostream:

void get_data(CDAccount& the_account)

{

    cout << "Enter account balance: $";

    cin >> the_account.balance;

    cout << "Enter account interest rate: ";

    cin >> the_account.interest_rate;

    cout << "Enter the number of months until maturity "

         << "(must be 12 or fewer months): ";

    cin >> the_account.term;

}

Using the program 10.1 as a template, write a program to do the following:

Declare a structure called CustomerRecord, which holds

first name

last name

street address

city

state

zip

age (full years)

hourly rate (format $99.99)

hours worked

      Use the appropriate data types

Declare and implement the readCustomerData function which populates a CustomerRecord passed by reference. Prompt the user to enter the data.

In the main, invoke the function to read in the data, and then print it out. Assemble the data in the following format with labels: (use for tab, or endl for new line)

Customer Name:      John Smith

Customer Address:   123 Blake St

Customer Address:   Denver, CO 80202

Customer Age:         25

Customer Rate:        $25.00

Customer Hours:      10

Customer Earnings:   $250.00

Explanation / Answer

#include <iostream>
using namespace std;

class CDAccount
{
public:
CDAccount();
CDAccount(double bal, double intRate, int T );
double InterestRate();
double InitialBalance();
double BalanceAtMaturity();
int Term();
void input(istream&);
void output(ostream&);
private:
  
  
int dollars;
int cents;
double interestRate;
int term;
};
CDAccount::CDAccount()
{
  
}
CDAccount::CDAccount(double bal, double intRate, int T )
{
dollars = int(bal);
cents = int(bal*1000);
interestRate = intRate/1000;
term = T;
}
double CDAccount::InterestRate()
{
return interestRate*1000;

}
double CDAccount::InitialBalance()
{
return dollars + cents/1000.00;
}
double CDAccount::BalanceAtMaturity()
{
return (dollars + cents/1000.0)*
(1+ (interestRate)*(term/12.0));
}
int CDAccount::Term()
{
return term;
}

void CDAccount::input(istream& inStream)
{
double dBal;
inStream >> dBal;
dollars = int(dBal);
cents = int((dBal - dollars)*1000);
inStream >> term;
}

void CDAccount::output(ostream& outStream)
{
outStream.setf(ios::fixed);
outStream.setf(ios::showpoint);
outStream.precision(2);

}
int main()
{
double balance;
double intRate;
int term;
CDAccount account = CDAccount( 500.0, 4.0, 8 );
cout << "Homework 5 Project 3" << endl;
cout << "Test Program for CDAccount class" << endl;
cout << endl;
cout << "Testing individual accessor functions:" << endl;
cout << endl;
cout << "First Account Initial Balance: $"
<< account.InitialBalance() << endl;
cout << "First Account Rate: "
<< account.InterestRate() << endl;
cout << "First Account term: " << account.Term()
<< " "<< endl;
cout << "First Account Final Balance: "
<< account.BalanceAtMaturity() << endl;
account.output( cout );
cout << endl;
cout << "Testing the member function that writes the summary of the object:" << endl;
cout << endl;
cout << "Account Values" << endl;
cout << "Initial Account Balance is $"
<< account.InitialBalance() << endl;
cout << "Interest Rate is "
<< account.InterestRate() << "%" << endl;
cout << "Term in months is " << account.Term()
<< " "<< endl;
cout << "Final Balance will be $"
<< account.BalanceAtMaturity() << endl;
account.output( cout );
cout << endl;
cout << "Testing the member function that inputs object values:"
<< endl << endl;
cout << "Please enter values for"
   << endl << endl;
cout << "Initial balance, Interest Rate, "
<< " and Term:" << endl;
account.input(cin);
cout << "Testing the member function that writes the summary of the object:" << endl;
cout << endl;
cout << "Initial Account balance: "
<< account.InitialBalance() << endl;
cout << "Interest Rate is "
<< account.InterestRate() << endl;
cout << "Term in month is " << account.Term()
<< " "<< endl;
cout << "Final Balance will be $"
<< account.BalanceAtMaturity() << endl;
account.output( cout );
cout << endl;

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote