(Invoice class

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 pieces of information as instance variables— a part number (type string), a part description (type string), a quantity of the item being purchased (type int) and a price per item (decimal). Your class should have a constructor that initializes the four instance variables. Provide a property with a get and set accessor for each instance variable. In addition, provide a method named GetInvoiceAmount that calculates the invoice amount (i.e., multiplies the quantity by the price per item), then returns the amount as a decimal value. If the quantity is negative, it should be left unchanged. Similarly, if the price per item is negative, it should be left unchanged. Write a test application named InvoiceTest that demonstrates class Invoice’s capabilities.

Recommended Answers

All 7 Replies

So, you know what you have to do, do it. :)

class invoice { 
... 
};

Something like that.

seems like you haven't even tried to solve a problem .
we are not here to do your homework.

You should do this your self,
I will just show you a few things to get started with:

#include <iostream>
#include <math.h>

//Here are the variables//
string partnum;
string descript;
int quan;
double price;

int main(int nNumberofArgs, char* pszArgs[]) {
  //Coding for program starts here//
}

And you write the program I just gave you the beginning.
Hope this helps :D

int main(int nNumberofArgs, char* pszArgs[]) {

Coders will have your head for not using argc and argv. xD

Coders will have your head for not using argc and argv. xD

And the lack of code-tags
And the use of global variables.
And posting absolutely unrelated code to the OP original problem.

On topic: Here's a tutorial on Classes, it will help you (OP) to get started.

>Coders will have your head for not using argc and argv. xD
Nah, but the hungarian notation will start wars. ;)

commented: Let's not go down that road :) +15

did someone say "war"?

Encoding the type of a function into the name (so-called Hungarian notation) is brain damaged - the compiler knows the types anyway and can check those, and it only confuses the programmer. No wonder MicroSoft makes buggy programs.

--Linus Torvalds
The Linux Kernel Documentation
http://lxr.linux.no/linux+v2.6.29/Documentation/CodingStyle#L237

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.