SophiaPretty

(5)

$14/per page/Negotiable

About SophiaPretty

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Accounting,Algebra See all
Accounting,Algebra,Applied Sciences,Architecture and Design,Art & Design,Biology,Business & Finance,Calculus,Chemistry,Communications,Computer Science,Economics,Engineering,English,Environmental science,Essay writing Hide all
Teaching Since: Jul 2017
Last Sign in: 214 Weeks Ago
Questions Answered: 15833
Tutorials Posted: 15827

Education

  • MBA,PHD, Juris Doctor
    Strayer,Devery,Harvard University
    Mar-1995 - Mar-2002

Experience

  • Manager Planning
    WalMart
    Mar-2001 - Feb-2009

Category > Communications Posted 16 Dec 2017 My Price 8.00

friend istream& operator>>(istream&, savingsAcct&);

USING MULTIPLE FILES I HAVE TO COMPILE THIS IN PUTTY. BUT I AM GETTING ERROR. SO IF ANYONE CAN HELP ME COMPILING THIS THROUGH MULTIPLE FILES IN PUTTY AND ALSO TELLING ME WHY AM I GETTING ERROR AND WHERE ! THANK YOU (ASAP)

#include <iostream> 

using namespace std;

 

class savingsAcct

{

friend istream& operator>>(istream&, savingsAcct&);

friend ostream& operator<<(ostream&, const savingsAcct&);

public:

savingsAcct();

savingsAcct(string acctNum, double amt);

// Postcondition: balance is set to the value passed to parameter amt

static double * getAddressOfVar_annulRate();

// Postcondition: return the address of static variable annualRate (should be the same for all objects!)

static double getAnnualRate();

// Postcondition: returns annual interest rate

static void setAnnualRate(double rate); // change the annual interest rate

// Postcondition: annualRate has been changed to the value passed to parameter rate

void computeInterest();

// Interest is computed at the end of each month using monthly interest rate (i.e.,annualRate/12)

// Postcondition: interest is computed at the end of the month using the current balance

private:

string acctNo; // e.g., A1234

double balance;

static double annualRate; // classwide; store in a memory location shared by all objects

double interest; // monthly interest

};

 

//initializing of the first scope

double savingsAcct::annualRate = 0.0;

 

savingsAcct::savingsAcct() 

 {

  acctNo = "";

  balance = 0.0;

  interest = 0.00; 

 }

 

savingsAcct::savingsAcct(string acctNum, double amt)

{

acctNo = acctNum;

balance = amt;

}

 

double* savingsAcct::getAddressOfVar_annulRate()

{

return &annualRate;

}

 

double savingsAcct::getAnnualRate()

{

return annualRate;

}

 

void savingsAcct::setAnnualRate(double rate)

{

annualRate = rate;

}

 

 

void savingsAcct::computeInterest()

{

interest = (annualRate * balance)/12 ; 

}

 

  istream& operator>>(istream& input, savingsAcct& sobj)

  {

      cout << "Enter account number and balance:" << endl;

      cin >> sobj.acctNo >> sobj.balance;

      return input;

      

  }

  ostream& operator<<(ostream& output, const savingsAcct& sobj)

  {

      cout << "Account Number:t" << sobj.acctNo << endl;

      cout << "Balance:t" << sobj.balance << endl;

      cout << "Interest:t" << sobj.interest << endl;

      return output;

  }

 

 

 

int main()

{

cout << "As of now, no object has been declared.n";

cout << "However, static data members exist before any object is declared:" << endl;

cout << " The address of its storage location: " 

<< int(savingsAcct::getAddressOfVar_annulRate()) << endl;

cout << "         Annual interest rate: " << savingsAcct::getAnnualRate() * 100 

<< "%" << endl << endl;

 

cout << "Still no object has declared, we now set the interest rate to 1.5%." << endl;

savingsAcct::setAnnualRate(0.015);

cout << "  Now, the annual interest rate is: " << savingsAcct::getAnnualRate() * 100 

<< "%" << endl << endl;

 

cout << "We now declare and initialize 2 savingAcct objects." << endl;

cout << "We also compute interest at the end of 1st month and display their contents:nn";

savingsAcct s1("A1234", 5000), s2("A9876", 8000);

s1.computeInterest();

s2.computeInterest();

cout << s1 << endl << endl;

cout << s2 << endl << endl;

cout << "We now display the address of static variable annualRate" << endl;

cout << " by calling "getAddressOfVar_annulRate()" member function" << endl << endl;

 

cout << "Via s1: the address of "annualRate" is " << int(s1.getAddressOfVar_annulRate()) << endl;

cout << "Via s2: the address of "annualRate" is " << int(s2.getAddressOfVar_annulRate()) << endl;

cout << "Via s1: the address of "annualRate" is " << int(savingsAcct::getAddressOfVar_annulRate()) << endl;

cout << "nIt should be quite clear that static members are indeed "class-wide!!!"" << endl;

cout << "Note: calling a static member function, "this" pointer is not involved!!!nn";

system ("pause");

    return 0;

}

Answers

(5)
Status NEW Posted 16 Dec 2017 06:12 AM My Price 8.00

-----------  ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly

Not Rated(0)