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

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

ID: 3760169 • Letter: U

Question

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

//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;

}

Explanation / Answer

#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;
}