Answered Essay: Task: Create a C++ project that will have 3 source files: a main file (driver

Task: Create a C++ project that will have 3 source files: a main file (driver program), a class specification file (header file), and a class implementation file. The project will be a simple inventory program to manage your coin collection.


The Coin class will contain the following data members:

year                an int for the year the coin was minted

faceValue       a double for holding the original value of the coin

description    a dynamically-allocated string holding a description of the coin

quantity         an int for holding the quantity on-hand of this coin

marketValue a double for holding the estimated current market value of this coin

totalValue      a static member that holds the total market value of the collection

The Coin class will need these member functions:

a constructor function to initialize the data attributes

a destructor function

mutator functions to change the values of each data member. The mutator functions should include basic input validation so that negative numbers are not stored in the quantity or value members, and that year is in an appropriate range (for the sake of simplicity, you may assume that you do not have access to coins created in the B.C. era). Be sure to update the static member as needed.

accessor functions to retrieve the data values

a function to calculate the difference between a coin’s faceValue and its marketValue

Main processing: Create an array of Coin objects, instantiating at least 3 objects. The driver program should utilize/demonstrate each of the class functions. The driver should be able to display the collection. If needed, you may use the array index as a record key to access different coins. Make sure you program is well documented both internally and externally.

Input: Data may be input by the user or you may create a data file and read the values into your array. If you use a data file, be sure to submit it with your source code files.

Output: Results will be displayed to the screen.

Expert Answer


Please find below the required 3 files and Console output:

save the below code as Coin.h

/*header file Coin class*/


using namespace std;

#ifndef COIN_H

#define COIN_H

//static variable for total value

static double totalValue;

class Coin{

//data members


int year;

double faceValue;

string description;

int quantity;

double marketValue;



Coin(int y,double fv,string desc,int q,double mv);



void setYear(int y);

void setFaceValue(double fv);

void setDescription(string desc);

void setQuantity(int q);

void setMarketValue(double mv);

int getYear();

double getFaceValue();

string getDescription();

int getQuantity();

double getMarketValue();



save the below code as Coin.cpp



#include “Coin.h”

using namespace std;

//Constructors ans desctructors



Coin::Coin(int y,double fv,string desc,int q,double mv)


year = y;

faceValue = fv;

description = desc;

quantity = q;

marketValue = mv;




//mutators and accessors basic validation

//for checking negative numbers

void Coin::setYear(int y)




cout<<“Ivalid year n”;

year = 1000;



year = y;


void Coin::setFaceValue(double fv)




cout<<“face Value can be negative , setting to 0n”;

faceValue = 0;



faceValue = fv;


void Coin::setDescription(string desc)


description = desc;


void Coin::setQuantity(int q)




cout<<“Quantity can not be negative , setting to 0n”;

quantity = 0;



quantity = q;


void Coin::setMarketValue(double mv)




cout<<“Market value can not be negative, setting to 0n”;

marketValue = 0;



marketValue = mv;

//static field total value updating

totalValue = totalValue+mv*quantity;



int Coin::getYear()


return year;


string Coin::getDescription()


return description;


double Coin::getFaceValue()


return faceValue;


double Coin::getMarketValue()


return marketValue;


int Coin::getQuantity()


return quantity;


//method for getting diff of facevalue and market value

double getFaceAndMarketValueDiff(Coin c)


return c.getFaceValue()-c.getMarketValue();


//save the below code as CoinMain.cpp


#include “Coin.cpp”

using namespace std;

int main()


//Coin array for 3 objects

Coin c[3];

int year,quant;

string desc;

double fv,mv;

//for each Coin asking the value

for(int i=0;i<3;i++)


cout<<“Enter the Info for Coin : “<<i+1<<endl;

cout<<“Enter the year : “;


cout<<“Enter the face value of coin : “;


cout<<“Enter the market value of coin : “;


cout<<“Enter the quantity of coin : “;


cout<<“Enter the description of coin : “;



//using mutators setting the value








//printing the values using accessors

for(int j=0;j<3;j++)


cout<<“Coin “<<j+1<<” Information : n”;

cout<<“Coin Description : “<<c[j].getDescription()<<endl;

cout<<“Coin Minted Year : “<<c[j].getYear()<<endl;

cout<<“Coin Face Value : “<<c[j].getFaceValue()<<endl;

cout<<“Coin Market Value : “<<c[j].getMarketValue()<<endl;

cout<<“Coin Quantity : “<<c[j].getQuantity()<<endl;

cout<<“Face and Market value difference : “<<getFaceAndMarketValueDiff(c[j])<<endl;



cout<<“nTotal Value of coin : “<<totalValue;

return 0;



Buy Essay
Calculate your paper price
Pages (550 words)
Approximate price: -

Help Me Write My Essay - Reasons:

Best Online Essay Writing Service

We strive to give our customers the best online essay writing experience. We Make sure essays are submitted on time and all the instructions are followed.

Our Writers are Experienced and Professional

Our essay writing service is founded on professional writers who are on stand by to help you any time.

Free Revision Fo all Essays

Sometimes you may require our writers to add on a point to make your essay as customised as possible, we will give you unlimited times to do this. And we will do it for free.

Timely Essay(s)

We understand the frustrations that comes with late essays and our writers are extra careful to not violate this term. Our support team is always engauging our writers to help you have your essay ahead of time.

Customised Essays &100% Confidential

Our Online writing Service has zero torelance for plagiarised papers. We have plagiarism checking tool that generate plagiarism reports just to make sure you are satisfied.

24/7 Customer Support

Our agents are ready to help you around the clock. Please feel free to reach out and enquire about anything.

Try it now!

Calculate the price of your order

Total price:

How it works?

Follow these simple steps to get your paper done

Place your order

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Receive the final file

Once your paper is ready, we will email it to you.


Let us write that nagging essay.


Submit Your Essay/Homework Instructions

By clicking on the "PLACE ORDER" button, tell us your requires. Be precise for an accurate customised essay. You may also upload any reading materials where applicable.


Pick A & Writer

Our ordering form will provide you with a list of writers and their feedbacks. At step 2, its time select a writer. Our online agents are on stand by to help you just in case.


Editing (OUR PART)

At this stage, our editor will go through your essay and make sure your writer did meet all the instructions.


Receive your Paper

After Editing, your paper will be sent to you via email.