geting the default costructor in class using array

Nov 24, 2011 at 3:42am
cashRegisiter class simulates the sale of a product. Cashregisiter has an array that can hold retailItem objects, a constant for VAT rate and a variable to store total sales
(1) default constructor to initializes the class data retailItem with a max of 10 objects
(2)class getSubtotal that returns the sum of the quanity multiply by the retail price for the retailItem stored

any one can help??

Last edited on Nov 24, 2011 at 4:47am
Nov 24, 2011 at 4:19am
What?
Nov 24, 2011 at 4:45am
class retailitem
{
private:
double RP // variable for retail price
string PD // variable for product description
string num1 // variable for item
public:
retailitem(double RP, string PD, string num1);
string getdescription() const;
string getItem () const;
double getRetailprice ();
}

retailitem::retailitem(double RP, string PD, string num1);
: RP(RP),
PD(PD),
num1(num1)
{
}


this the first part of the program
the accessor methods for getting the values of retailitem have been done
which is class in a class
Last edited on Nov 24, 2011 at 4:48am
Nov 24, 2011 at 4:51am
BLACKHULK wrote:
this the first part of the program
the accessor methods for getting the values of retailitem have been done
which is class in a class
I read that as, "This is the first part of the program. The accesor methods for getting the values of retalitem have already been done. (I can't understand the last sentence.)"

What is your question/problem?
Nov 24, 2011 at 5:03am
this is the problem?

cashRegisiter class simulates the sale of a product. Cashregisiter has an array that can hold retailItem objects, a constant for VAT rate and a variable to store total sales

question how do you get:
(1) default constructor to initializes the class data with appropriate values. the array of the class retailItem will hold a max of 10 objects

question how do you go about:
(2)class getSubtotal that returns the sum of the quanity multiply by the retail price for all the retailItem stored in the class.
Nov 24, 2011 at 5:13am
Something like this:
1
2
3
4
5
6
7
8
9
10
11
12
class cashRegisted {
 private:
    retailItem items[10];
    int itemsLength;

 public:
    cashRegister() : itemsLength(0) {}

    double getSubtotal() const;
    void addItem(const retailItem&);
    void removeItem(const retailItem&);
};

I'm not sure I completely understand the calculations you need to do. What is the "VAT rate?" What do you mean by "returns the sum of the quanity multiply by the retail price for all the retailItem?" Did you mean method getSubtotal, instead of class getSubtotal, because verbs are usually methods, where as classes are usually nouns.
Last edited on Nov 24, 2011 at 5:14am
Nov 24, 2011 at 5:21am
getSubtotal is the right way not a classes
VAT rate is part of the public

where their is more questions to this problem where you have to

getTAX : method of should return the amount o sales tax/VAT on the purchase tax rate =6% of the subtotal.

and

getTotal : that returns the total value of the sale. which is subtotal plus the sales tax.

Last edited on Nov 24, 2011 at 5:29am
Nov 24, 2011 at 6:46am
VAT might be public, but what does it mean/do?
Nov 24, 2011 at 12:00pm
VAT is a way taxing the products
Topic archived. No new replies allowed.