-
February 6th, 2009, 10:56 AM
#1
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.
-
February 6th, 2009, 11:05 AM
#2
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.
-
February 6th, 2009, 11:06 AM
#3
Re: Help!!
Originally Posted by budgestreetbandit
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
-
February 6th, 2009, 11:12 AM
#4
Re: Help!!
Originally Posted by 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
-
February 6th, 2009, 01:38 PM
#5
Re: Help!!
Originally Posted by TheCPUWizard
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
-
February 9th, 2009, 03:55 PM
#6
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
-
April 8th, 2009, 05:05 AM
#7
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
-
April 8th, 2009, 07:11 AM
#8
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|