1. Welcome to Tacoma World!

    You are currently viewing as a guest! To get full-access, you need to register for a FREE account.

    As a registered member, you’ll be able to:
    • Participate in all Tacoma discussion topics
    • Communicate privately with other Tacoma owners from around the world
    • Post your own photos in our Members Gallery
    • Access all special features of the site

C++ Assignment help

Discussion in 'Technology' started by tarheelfan_08, Feb 15, 2010.

  1. Feb 18, 2010 at 7:53 PM
    #61
    tarheelfan_08

    tarheelfan_08 [OP] Carolina Alliance

    Joined:
    Jan 4, 2008
    Member:
    #4098
    Messages:
    2,944
    Gender:
    Male
    First Name:
    Justin
    North Carolina
    Vehicle:
    2010 White 4x4 Double Cab Tacoma Short Bed
    Chrome Grill, Chrome accessories(door handles and mirror covers), LEER Super White Cover, Mirrors with Turn Signals, Window Vent Visors, Step Rails, WeatherTech Digital Floor Mats, Mini Maglight Holder, Chrome Bull Bar
    Anyone got any help for me on these last errors??
     
  2. Feb 18, 2010 at 9:15 PM
    #62
    tarheelfan_08

    tarheelfan_08 [OP] Carolina Alliance

    Joined:
    Jan 4, 2008
    Member:
    #4098
    Messages:
    2,944
    Gender:
    Male
    First Name:
    Justin
    North Carolina
    Vehicle:
    2010 White 4x4 Double Cab Tacoma Short Bed
    Chrome Grill, Chrome accessories(door handles and mirror covers), LEER Super White Cover, Mirrors with Turn Signals, Window Vent Visors, Step Rails, WeatherTech Digital Floor Mats, Mini Maglight Holder, Chrome Bull Bar
    Well project has been turned in with errors...now I just got to figure out how to do it so that it does not bother me forever lol...and so i have it for future reference!!
     
  3. Feb 20, 2010 at 10:18 PM
    #63
    tarheelfan_08

    tarheelfan_08 [OP] Carolina Alliance

    Joined:
    Jan 4, 2008
    Member:
    #4098
    Messages:
    2,944
    Gender:
    Male
    First Name:
    Justin
    North Carolina
    Vehicle:
    2010 White 4x4 Double Cab Tacoma Short Bed
    Chrome Grill, Chrome accessories(door handles and mirror covers), LEER Super White Cover, Mirrors with Turn Signals, Window Vent Visors, Step Rails, WeatherTech Digital Floor Mats, Mini Maglight Holder, Chrome Bull Bar
    Hey guys when I run the following program the command prompt pops up but the data does not load can someone tell me what I am doing wrong.

    customer.h
    Code:
    
    #ifndef CUSTOMER_H
    #define CUSTOMER_H
    
    #include <iostream>
    #include <fstream>
    #include <iomanip>
    #include <functional>
    #include <algorithm>
    #include <string>
    #include <cstdlib>
    #include <sstream>
    using namespace std;
    
    //Customer Class
    class Customer {
    private:
        string name;  //name of customer
        string ssn; // social security number
        string address;  // address
        string birthDate;      //birth date
        double savings;  // savings account balance
        double checking;  // checking account balance
        double balance;    // Consoldated Balance
    
    public:
        Customer(); //constructor
        Customer(string, string, string, string ,int, int);
        void setName(string);
        void setSSN(string);
        void setAddress(string);
        void setBirthDate(string);
        void setSavings(double);
        void setChecking(double);
            void setBalance(double);
            
            void operator +=( double );
            void operator -=( double );
            void operator ++ ();
    
        string getName();
        string getSSN();
        string getAddress();
        string getBirthDate();
        double getSavings();
        double getChecking();
        double getBalance();
    
            void displayCustomer();
            string string_displayCustomer();
    
    
    };
    
    
    //-----------------------------------------------------------------------------
    //class definition
    Customer::Customer() {
        name = " ";
        ssn = " ";
        address = " ";
        birthDate = " ";
        savings = 0;
            checking = 0;
            balance = 0;
    }
    
    Customer::Customer(string name, string ssn, string address, string birthDate, int savings, int checking) {
        Customer::name =  name;
        Customer::ssn = ssn;
        Customer::address = address;
        Customer::birthDate = birthDate;
        Customer::savings = savings;
        Customer::checking = checking;
        Customer::balance = balance;
    }
    
    void Customer::setName(string name) {
        Customer::name = name;
    }
    
    void Customer::setSSN(string ssn) {
        Customer::ssn = ssn;
    }
    
    void Customer::setAddress(string address) {
        Customer::address = address;
    }
    
    void Customer::setBirthDate(string birthDate) {
        Customer::birthDate = birthDate;
    }
    
    void Customer::setSavings(double savings) {
        Customer::savings = savings;
    }
    
    void Customer::setChecking(double checking) {
        Customer::checking = checking;
    }
    
    void Customer::setBalance(double balance) {
            Customer::balance = balance;
    }
    
    
    
    string Customer::getName() {
        return name;
    }
    
    string Customer::getSSN() {
        return ssn;
    }
    
    string Customer::getAddress() {
        return address;
    }
    
    string Customer::getBirthDate() {
        return birthDate;
    }
    
    double Customer::getSavings() {
        return savings;
    }
    
    double Customer::getChecking() {
        return checking;
    }
    
    double Customer::getBalance() {
            return balance;
    
    }
    
    void Customer::displayCustomer() {
        cout << "The current customer is " << name << ", their address is " << address << ", and their Social Security Number is "
                    << ssn << ".  "  << name << "'s Saving Account Ballance is:" << savings << ".  The Checking Account Balance is:" << checking << ".\n";
            cout << "The consolidated balance is: $" << balance << ".\n";
    }
    
    string Customer::string_displayCustomer() {
            stringstream buf;
            cout << "The current customer is " << name << ", their address is " << address << ", and their Social Security Number is "
            << ssn << ".  "  << name << "'s Saving Account Ballance is:" << savings << ".  The Checking Account Balance is:" << checking << ".\n";
            cout << "The consolidated balance is: $" << balance << ".\n";
        return buf.str();
    }
    void Customer::operator += ( double dValue ) {
            setBalance( getBalance()+ dValue );
                    //return this;
        }
    void Customer::operator -= ( double dValue ) {
            setBalance( getBalance() - dValue );
                    //return this;
        }
    
    void Customer::operator ++ () {
           
          setBalance(getSavings()  +  getChecking());
     }
    
    #endif
    
    Account.h
    Code:
    #ifndef ACCOUNT_H
    #define ACCOUNT_H
    
    #include "Customer.h"
    
    //Account Class
    class Account {
    private:
            Customer myCustomer[2];
            string type;
            int number;
        double balance;
        double rate;
            double intrest;
            double NewBalance;
    
    public:
            Account(); // Constructor
            Account(string, int, double, double) ;
                    void setType(string);
                    void setNumber(int);
                    void setBalance(double);
                    void setRate(double);
    
                    string getType();
                    int getNumber();
                    double getBalance();
                    double getRate();
                    Customer& getCustomer ( int );
                    void valid_rate(double);
                    void ApplyInterest();
                    void operator += (Account& a);
                    void operator -= (Account& a);
                    void operator ++ (int n );
    
                    };      
    //-----------------------------------------------------------------------------
    //class definition
            Account::Account() {
                    type = " ";
                    number = 0;
                    balance = 0;
                    rate = 0;
            }
    
            Account::Account(string type, int number, double balance, double rate) {
                    Account::type = type;
                    Account::number = number;
                    Account::balance = balance;
                    valid_rate(rate);
                    }
    void Account::setType(string type) {
        Account::type = type;
    }
    
    void Account::setNumber(int number) {
        Account::number = number;
    }
    
    void Account::setBalance(double balance) {
        Account::balance = balance;
    }
    
    void Account::setRate(double rate) {
            valid_rate(rate);
    }
    
    string Account::getType() {
        return type;
    }
    int Account::getNumber() {
        return number;
    }
    double Account::getBalance() {
        return balance;
    }
    double Account::getRate() {
        return rate;
    }
    
    void Account::valid_rate(double rate) {
            if (rate >=.01 && rate <= .1)
                    Account::rate=rate;
            else {
                    Account::rate=0;
                    cout << "WARNING! You have entered an invalid rate!\n";
            }
    }
    
    void Account::ApplyInterest() {
                    intrest = rate * balance;
                    NewBalance = intrest + balance;
                    cout << "The amount of intrest for the Customer is: $" << intrest << " and the account balance is: $" << NewBalance << ".\n";
    }      
    
    
    Customer& Account::getCustomer(int n) {
            return myCustomer[n];
    }
    
       // void operator += (Account& a) {
        void Account::operator+= (Account& a) {
            setBalance(getBalance()+ a.getBalance());
        }
    
        //void operator -= (Account& a) {
        void Account::operator-= (Account& a) {
            setBalance(getBalance() - a.getBalance());
        }
    
        void Account::operator++ (int n ) {
                    //Customer::balance(Customer::savings + Customer::checking);
            myCustomer[0] += myCustomer[0].getSavings() + myCustomer[0].getChecking();
            myCustomer[1] += myCustomer[1].getSavings() + myCustomer[1].getChecking();        
        }
    
    #endif
    
    test.cpp
    Code:
    #include "Account.h"
    #include "Customer.h"
    #include "Date.h"
    #include <iostream>
    using namespace std;
    
    
    
    
    int main() {
        Customer myCust[2];
        Account myInterest[2];
        int current_cust=0;
            Customer *myCustomer[2];
            myCustomer[0] = new Customer("Justin Puckett", "244-13-4567", "115 Fairbanks Court Mount Airy, NC", "May 17th 1990", 500, 1000);
            myCustomer[1] = new Customer("Shaina Parker", "244-13-0002", "234 Farmbrook Rd Mount Airy, NC", "May 27th 1990", 800, 2000);
            
            for(int x=0; x<2; x++)
            myCust[x].displayCustomer();
            for(int d=0; d<2; d++)
            myInterest[d].ApplyInterest();
    
            return 0;
    }
    
     

Products Discussed in

To Top