CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8

Thread: Help!!

  1. #1
    Join Date
    Feb 2009
    Posts
    1

    Question Help!!

    Dear everyone,

    I am currently in the process of learning C++ for the first time (using Deitel 6th edition) and I seem to be having trouble with some of the review exercises. Help writing this code would be much appreciated. Please keep in mind that I am only at Chapter 3 so please try to avoid more advanced functions etc.
    Here's the question:

    Create a class called Invoice that a hardware store might use to represent an invoice for an item sold at the store. An Invoice should include four data members -- a part number (type string), a part description (type string), a quantity of the item being purchased (type int) and a price per item (type int). Your class should have a constructor that initializes the four data members. Provide a set and a get function for each data member. In addition, provide a member function named getInvoiceAmount that calculates each data member (i.e. multiplies the quantity by the price per item), then returns the amount as an int value. If the quantity is not positive, it should be set to 0. If the price per item is not positive, it should be set to 0. Write a test program that demonstrates class Invoice's capabilities.

  2. #2
    Join Date
    Sep 2004
    Location
    Holland (land of the dope)
    Posts
    4,123

    Re: Help!!

    Hi, and welcome to CodeGuru.

    We are not here to actually write code for you, but we only help to find errors in your code. So, first try it yourself and if then post some code you can't get to work.

  3. #3
    Join Date
    Apr 1999
    Posts
    27,449

    Re: Help!!

    Quote Originally Posted by budgestreetbandit View Post
    Dear everyone,

    I am currently in the process of learning C++ for the first time (using Deitel 6th edition) and I seem to be having trouble with some of the review exercises. Help writing this code would be much appreciated.
    http://www.codeguru.com/forum/showthread.php?t=366302
    Please keep in mind that I am only at Chapter 3 so please try to avoid more advanced functions etc.
    What if we don't have this book? How would we know what is "advanced" or not? What may be advanced to you may be beginner material to someone else.

    Please show what you've done.

    Regards,

    Paul McKenzie

  4. #4
    Join Date
    Mar 2002
    Location
    St. Petersburg, Florida, USA
    Posts
    12,125

    Re: Help!!

    Quote Originally Posted by Paul McKenzie View Post
    http://www.codeguru.com/forum/showthread.php?t=366302
    What if we don't have this book? How would we know what is "advanced" or not? What may be advanced to you may be beginner material to someone else.

    Please show what you've done.

    Regards,

    Paul McKenzie
    Paul,

    While I agree with your comments, I think a big "Kudos" is due to the OP for actually taking the time to properly follow a book, rather than "randomly" picking up bits and pieces (along with wrong information, and bad assumptions).

    Although many may not have the specific book, I believe it is helpful when people post the book they are using and the chapter they are up.
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009,2010
    In theory, there is no difference between theory and practice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

  5. #5
    Join Date
    Apr 1999
    Posts
    27,449

    Re: Help!!

    Quote Originally Posted by TheCPUWizard View Post
    Paul,

    While I agree with your comments, I think a big "Kudos" is due to the OP for actually taking the time to properly follow a book, rather than "randomly" picking up bits and pieces (along with wrong information, and bad assumptions).
    Yes, that's true. Although it would be good if at the same time, they give what they have learned, so that others who do not have the book have some idea of what they are looking for.

    Regards,

    Paul McKenzie

  6. #6
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,620

    Re: Help!!

    Help writing this code would be much appreciated.
    What is your plan about getting that help? What should it look like?

    Besides, the task desciption sounds perfectly clear, and this only part "Write a test program that demonstrates class Invoice's capabilities." may require for some effort/imagination.
    Last edited by Igor Vartanov; February 9th, 2009 at 04:02 PM.
    Best regards,
    Igor

  7. #7
    Join Date
    Apr 2009
    Posts
    1

    Re: Help!!

    anyways if you need help with deitel exercises then email me. Lets respect the forum rules and not do all of it here. my email is emanuelu4[at]gmail.com

  8. #8
    Join Date
    Apr 2009
    Posts
    21

    Re: Help!!

    Learn the class syntax

    Code:
    class myClass
    {
    public:
         // here goes stuff that controls my data
    private:
         // here goes my data
    };

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured