can anybody fix this program for me ASAP

This is a discussion on can anybody fix this program for me ASAP within the C++ Programming forums, part of the General Programming Boards category; Code: OvernitPackage.cpp #include "OvernitPackage.h" OvernitPackage::OvernitPackage(string SF, string RF, string SAD,string RAD, string SCT, string SST, int SZP,string RCT, string RST, ...

  1. #1
    Registered User
    Join Date
    Apr 2006
    Posts
    1

    can anybody fix this program for me ASAP

    Code:
    
    OvernitPackage.cpp
    #include "OvernitPackage.h"
    
    
    OvernitPackage::OvernitPackage(string SF, string RF, string SAD,string RAD,
    string SCT, string SST, int SZP,string RCT, string RST, int RZP,double
    CS,double W, double CO,double OverR):Package(
    SF,RF,SAD,RAD,SCT,SST,SZP,RCT,RST,RZP,CS,W,CO)
    {
       SetOvernitRate(OverR);
    
    }
    
    OvernitPackage::~OvernitPackage()
    {
    
    }
    
    
    void OvernitPackage::SetOvernitRate(double OverR)
    {
       OvernitRate=OverR;
    
    }
    
    double OvernitPackage::GetOvernitRate()
    {
       return OvernitRate;
    }
    
    
    void OvernitPackage::calculateCost(double CS, double W, double CO, double
    OverR)
    {
       if ( CO>=0 && W>=0)
       {
           CS=(CO+OverR)*W;
    
       }
    
    }
    
    double OvernitPackage::GetcalculateCost()
    {
       return Cost;
    }
    
    
    
    
    
    OvernitPackage.h
    #ifndef OVERNITPACKAGE_H
    #define OVERNITPACKAGE_H
    
    #include <string>
    #include <iostream>
    using namespace std;
    
    #include "Package.h"
    
    
    class OvernitPackage : public Package
    {
    
    public:
       OvernitPackage(string SF, string RF, string SAD,string RAD, string SCT,
    string SST,int SZP,string RCT, string RST, int RZP,double CS,double W,
    double CO,double OverR);
       ~OvernitPackage();
    
       void SetOvernitRate(double OverR);
       double GetOvernitRate();
    
       void calculateCost(double CS,double W, double CO, double OverR);
       double GetcalculateCost();
    
    
    
    private:
    
       double OvernitRate;
    
       double Weight;
       double CostPerOunce;
       double Cost;
    
    
    
    };
    
    #endif
    
    
    
    
    Package.cpp
    #include "Package.h"
    
    Package::Package(string SF, string RF, string SAD,string RAD, string SCT,
    string SST, int SZP,string RCT, string RST, int RZP,double CS,double W,
    double CO)
    {
       SetSenderName(SF);
    
       SetRecipientName(RF);
    
       SetSenderAddress(SAD);
    
       SetRecipientAddress(RAD);
    
       SetSenderCity(SCT);
    
       SetSenderState(SST);
    
       SetSenderZipCode(SZP);
    
       SetRecipientCity(RCT);
    
       SetRecipientState(RST);
    
       SetRecipientZipCode(RZP);
    
       calculateCost(CS, W,  CO);
    
       GetcalculateCost();
    
    }
    
    Package::~Package()
    {
    
    
    }
    
    void Package::SetSenderName(string SF)
    {
    
       cout<<"What is sender's name?"<<endl;
       Sender=SF;
    
    }
    
    string Package::GetSenderName()
    {
       return Sender;
    
    }
    
    void Package::SetSenderAddress(string SAD)
    {
    
           //cout<<"Where is this mail sent from?"<<endl;
           SenderAddress=SAD;
    
    }
    
    string Package::GetSenderAddress()
    {
       return SenderAddress;
    
    }
    
    
    void Package::SetSenderCity(string SCT)
    {
       //cout<<"City of sender:"<<endl;
       SenderCtiy=SCT;
    
    }
    
    string Package::GetSenderCity()
    {
       return SenderCtiy;
    }
    
    void Package::SetSenderState(string SST)
    {
       //cout<<"State of sender:"<<endl;
       SenderState=SST;
    
    }
    
    string Package::GetSenderState()
    {
       return SenderState;
    
    }
    
    
    void Package::SetSenderZipCode(int SZP)
    {
       //cout<<"Zip Code of sender:"<<endl;
       SenderZip=SZP;
    
    }
    
    int Package::GetSenderZipCode()
    {
       return SenderZip;
    
    }
    
    void Package::SetRecipientName(string RF)
    {
    
       //cout<<"What is recipient's name?"<<endl;
       Recipient=RF;
    
    }
    
    string Package::GetRecipientName()
    {
       return Recipient;
    
    }
    
    void Package::SetRecipientAddress(string RAD)
    {
       //cout<<"Where is this mail going to ?"<<endl;
       RecipitientAddress=RAD;
    
    
    }
    
    string Package::GetRecipientAddress()
    {
       return RecipitientAddress;
    
    }
    
    
    
    void Package::SetRecipientCity(string RCT)
    {
       //cout<<"City of recipient:"<<endl;
       RecipientCtiy=RCT;
    
    }
    
    string Package::GetRecipientCity()
    {
       return RecipientCtiy;
    
    }
    
    
    void Package::SetRecipientState(string RST)
    {
       //cout<<"State of sender:"<<endl;
       RecipientState=RST;
    
    }
    
    string Package::GetRecipientState()
    {
       return RecipientState;
    
    }
    
    
    void Package::SetRecipientZipCode(int RZP)
    {
       //cout<<"Zip Code of Recipient:"<<endl;
       RecipientZip=RZP;
    
    }
    
    int Package::GetRecipientZipCode()
    {
       return RecipientZip;
    
    }
    
    void Package::calculateCost(double CS, double W, double CO)
    {
       if ( CO>=0 && W>=0)
       {
           CS=CO*W;
    
       }
    }
    
    double Package::GetcalculateCost()
    {
       return Cost;
    }
    
    
    
    Package.h
    
    #ifndef PACKAGE_H
    #define PACKAGE_H
    
    
    #include <string>
    #include <iostream>
    using namespace std;
    
    class Package
    {
    public:
    
       Package( string SF, string RF, string SAD,string RAD, string SCT, string
    SST,int SZP,string RCT, string RST, int RZP,double CS,double W, double CO);
       ~Package();
    
       void SetSenderName(string SF);
       string GetSenderName();
    
       void SetRecipientName(string RF);
       string GetRecipientName();
    
    
       void SetSenderAddress(string SAD);
       string GetSenderAddress();
    
       void SetRecipientAddress(string RAD);
       string GetRecipientAddress();
    
       void SetSenderCity(string SCT);
       string GetSenderCity();
    
       void SetSenderState(string SST);
       string GetSenderState();
    
       void SetSenderZipCode(int SZP);
       int GetSenderZipCode();
    
       void SetRecipientCity(string RCT);
       string GetRecipientCity();
    
       void SetRecipientState(string RST);
       string GetRecipientState();
    
       void SetRecipientZipCode(int RZP);
       int GetRecipientZipCode();
    
       void calculateCost( double CS,double W, double CO);
       double GetcalculateCost();
    
    
    
    private:
    
       string Sender;
       string Recipient;
       string SenderAddress;
       string RecipitientAddress;
       string SenderCtiy;
       string SenderState;
       string RecipientCtiy;
       string RecipientState;
    
       int RecipientZip;
       int SenderZip;
    
       double Weight;
       double CostPerOunce;
       double Cost;
    
    
    
    
    };
    
    #endif
    
    
    
    
    test.h
    
    #include "Package.h"
    #include "OvernitPackage.h"
    #include "TwoDayPackage.h"
    
    void main()
    {
    
    
    TwoDayPackage P;
    P.SetSenderName("");
    
    
    }
    
    
    
    
    TwoDayPackage.cpp
    
    #include "TwoDayPackage.h"
    
    
    TwoDayPackage::TwoDayPackage(string SF, string RF, string SAD,string RAD,
    string SCT, string SST,int SZP,string RCT, string RST, int RZP,double
    CS,double W, double CO,double
    FF):Package(SF,RF,SAD,RAD,SCT,SST,SZP,RCT,RST,RZP,CS,W,CO)
    {
       SetFlatFee(FF);
    
    
    }
    
    TwoDayPackage::~TwoDayPackage()
    {
    
    }
    
    void TwoDayPackage::SetFlatFee(double FF)
    {
       FlatFee=FF;
    }
    
    double TwoDayPackage::GetFlatFee()
    {
    
       return FlatFee;
    }
    
    void TwoDayPackage::calculateCost(double CS, double W, double CO, double FF
    )
    {
    
       if ( CO>=0 && W>=0)
       {
           CS=CO*W+FF;
    
       }
    }
    
    double TwoDayPackage::GetcalculateCost()
    {
       return Cost;
    
    }
    
    
    TwoDayPackage.h
    
    #ifndef TWODAYPACKAGE_H
    #define TWODAYPACKAGE_H
    
    #include <string>
    #include <iostream>
    using namespace std;
    #include "Package.h"
    
    
    
    class TwoDayPackage : public Package
    {
    
    public:
    
       TwoDayPackage( string SF, string RF, string SAD,string RAD, string SCT,
    string SST,int SZP,string RCT, string RST, int RZP,double CS,double W,
    double CO, double FF);
       ~TwoDayPackage();
    
       void SetFlatFee(double FF);
       double GetFlatFee();
    
       void calculateCost(double CS,double W, double CO, double FF);
       double GetcalculateCost();
    
    
    
    private:
       double FlatFee;
    
       double Weight;
       double CostPerOunce;
       double Cost;
    
    
    };
    
    #endif

  2. #2
    semi-colon generator ChaosEngine's Avatar
    Join Date
    Sep 2005
    Location
    Chch, NZ
    Posts
    597
    yes, I can fix it. I charge us$100 an hour.
    "I saw a sign that said 'Drink Canada Dry', so I started"
    -- Brendan Behan

    Free Compiler: Visual C++ 2005 Express
    If you program in C++, you need Boost. You should also know how to use the Standard Library (STL). Want to make games? After reading this, I don't like WxWidgets anymore. Want to add some scripting to your App?

  3. #3
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,066
    I'll do it for $99/h, but I get paid for lunch and can take one for as long as I'd like.
    Sent from my iPad®

  4. #4
    The Richness... Richie T's Avatar
    Join Date
    Jan 2006
    Location
    Ireland
    Posts
    469
    Number of problems here:

    1) No compiler/OS stated
    2) No hint of what the problem is
    3) No description of what the program is supposed to do via
    some sample input and expected output
    4) All code bunched together under one code tag instead of
    separate code tags for each file
    5) Code is pooly formatted besides - use the spacebar man!

    Two suggestions i can make (from some very skimmed reading)
    are:

    1) Avoid using so many getters and setters
    2) Perhaps it wouldn't be a bad idea to put all private variables
    into a struct called description, this would make passing values to
    overloaded constructors much easier than this:

    Code:
    TwoDayPackage( string SF, string RF, string SAD,string RAD, string SCT,
    string SST,int SZP,string RCT, string RST, int RZP,double CS,double W,
    double CO, double FF);
    Often it's not what you say but the way that you say it that
    motivates people to help you - thats why the two previous
    posters are essentially laughing - because the way that you have
    requested help is a bit ignorant.

    Overall, try reposting your question IN THIS THREAD, taking
    some of my suggestions on board, and you'll find people glad to
    help.
    No No's:
    fflush (stdin); gets (); void main ();


    Goodies:
    Example of fgets (); The FAQ, C/C++ Reference


    My Gear:
    OS - Windows XP
    IDE - MS Visual C++ 2008 Express Edition


    ASCII stupid question, get a stupid ANSI

  5. #5
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,420
    There - fixed.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Can someome help me with a program please?
    By WinterInChicago in forum C++ Programming
    Replies: 3
    Last Post: 09-21-2006, 10:58 PM
  2. Need help with my program...
    By Noah in forum C Programming
    Replies: 2
    Last Post: 03-11-2006, 06:49 PM
  3. Date program starts DOS's date
    By jrahhali in forum C++ Programming
    Replies: 1
    Last Post: 11-24-2003, 04:23 PM
  4. fopen();
    By GanglyLamb in forum C Programming
    Replies: 8
    Last Post: 11-03-2002, 11:39 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21