private void button1_Click(object sender, EventArgs e)
        {
            SalesTransaction s1 = new SalesTransaction(0.06);
            listBox1.Items.Add(s1.ToString());
            SalesTransaction s2 = new SalesTransaction("John Doe: ", 170000, 0.07); // 11900
           // s2.SalesAmount = 210000;
           //The commission should be automatically adjusted. 14700
            listBox1.Items.Add(s2.ToString());
            SalesTransaction s3 = new SalesTransaction("Jane Doe: ", 200000); // 0
            listBox1.Items.Add(s3.ToString());
            SalesTransaction s4 = new SalesTransaction("Tim Doe: "); // 0
            listBox1.Items.Add(s4.ToString());
            SalesTransaction s5 = s2 + s2;
            listBox1.Items.Add(s5.ToString());
        }
    }

    class SalesTransaction
    {
        private readonly double commissionRate; // page 386
        private decimal commission; // this is a calculated field
        public string Salesperson { get; set; } // auto-implemented property
        public decimal SalesAmount { get; set; }

        public double CommissionRate
        {
            get
            {
                return commissionRate;
            }
        }
        public decimal Commission
        {
            get
            {
                double salesNumber = Convert.ToDouble(SalesAmount);
                return commission = Convert.ToDecimal(salesNumber * commissionRate);
            }
        }
        public SalesTransaction(double rate)
        {
            commissionRate = rate;
        }
        public SalesTransaction(string disName, double Commie1, double rate)
        {
            commissionRate = rate;
            Salesperson = disName;
            SalesAmount = (decimal)Commie1;
        }
        (I have tried to finish this but im stuck here help me please)

Recommended Answers

What exactly are you stuck on? You haven't told us what you're trying to do.

Jump to Post

All 3 Replies

What exactly are you stuck on? You haven't told us what you're trying to do.

When you are providing extra information for an existing question, it is better to reply to your original question, rather than creating a new question.

In general, a constructor should set all applicable data members, even if not provided in the constructor arguments. Before using a list box to display something, it might be a good idea to clear the list box of any previous strings.
listbox1.clear();

Be a part of the DaniWeb community

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