Thread: I need help please.

  1. #1
    Registered User
    Join Date
    Oct 2012
    Posts
    3

    Angry I need help please.

    Here is what I need to accomplish, and I have attached my code. I cannot get it to compile correctly and I have no idea what I am doing wrong. Here are my errors.

    61:2 C:\C++\Untitled2.cpp invalid preprocessing directive #nclude
    \C++\Untitled2.cpp C:\C++\C Package.h: No such file or directory.
    \C++\Untitled2.cpp C:\C++\C TwoDayPackage.h: No such file or directory.
    304:8 C:\C++\Untitled2.cpp [Warning] extra tokens at end of #endif directive
    \C++\Untitled2.cpp C:\C++\C OvernightPackage.h: No such file or directory.
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    Oct 2012
    Posts
    3
    Opps, forgot to add the requirements.

    (Package Inheritance Hierarchy) Package-delivery services, such as FedEx®, DHL® and
    UPS®, offer a number of different shipping options, each with specific costs associated. Create an
    inheritance hierarchy to represent various types of packages. Use Package as the base class of the hierarchy,
    then include classes TwoDayPackage and OvernightPackage that derive from Package. Base
    class Package should include data members representing the name, address, city, state and ZIP code
    for both the sender and the recipient of the package, in addition to data members that store the
    weight (in ounces) and cost per ounce to ship the package. Package’s constructor should initialize
    these data members. Ensure that the weight and cost per ounce contain positive values. Package
    should provide a public member function calculateCost that returns a double indicating the cost
    associated with shipping the package. Package’s calculateCost function should determine the cost
    by multiplying the weight by the cost per ounce. Derived class TwoDayPackage should inherit the
    functionality of base class Package, but also include a data member that represents a flat fee that the
    shipping company charges for two-day-delivery service. TwoDayPackage’s constructor should receive
    a value to initialize this data member. TwoDayPackage should redefine member function calculate-
    Cost so that it computes the shipping cost by adding the flat fee to the weight-based cost calculated
    by base class Package’s calculateCost function. Class OvernightPackage should inherit directly
    from class Package and contain an additional data member representing an additional fee per ounce
    charged for overnight-delivery service. OvernightPackage should redefine member function calculateCost
    so that it adds the additional fee per ounce to the standard cost per ounce before calculating
    the shipping cost. Write a test program that creates objects of each type of Package and tests
    member function calculateCost.

  3. #3
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,130
    Read your errors carefully. Each one is very obvious and probably easy to solve. Start with the first and work down the list. If you don't understand what the error message is saying, post your best guess here.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  4. #4
    Registered User
    Join Date
    Oct 2012
    Posts
    3
    I don't understand why they are giving me errors. I fixed one of the errors, but I am still getting these. I am thoroughly confused. What am I overlooking?


    \C++\Untitled2.cpp C:\C++\C Package.h: No such file or directory.
    \C++\Untitled2.cpp C:\C++\C TwoDayPackage.h: No such file or directory.
    304:8 C:\C++\Untitled2.cpp [Warning] extra tokens at end of #endif directive
    \C++\Untitled2.cpp C:\C++\C OvernightPackage.h: No such file or directory.

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,656
    Well you copy/pasted the code from here.
    http://ftp0.timeorg.net/pub/book/pro...-PIE-SM_23.pdf

    > // Exercise 23.5 Solution: Package.h
    Do you see each of these comments?

    You need to split that massive copy/paste job into individual named files (as instructed).
    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.

  6. #6
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,130
    Well, you are including files. But if you look at the files you have... none of those you are including exists. It's very likely your big file was meant to be three or more files. There's even comments in the code that name them.

    If you remove all lines containing the words #include "something.h" it will compile. However, if this is not exactly what your teacher gave your for exercise 23.5, you may have to explain it...
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

Popular pages Recent additions subscribe to a feed