Create an application named SalesTransactiobDemo that declares several SalesTransaction objects and displays their values and their sum. Name - The salesperson name (as a string) sales Amount- The sales amount (as a double) commission- The commission (as a double) RATE- A readonly field that stores the commission rate (as a double). Define a getRate() avcessor method that returns the RATE Include 3 constructors for the class. One constructor accepts values for the name, sales amount, and rate, and when the sales value is set, the constructor computes the commission as sales value times commission rate. The second constructor accepts a name and sales amount, but sets the commission rate to 0 The third constructor accepts a name and sets all the other fields to 0
OOPs
In today's technology-driven world, computer programming skills are in high demand. The object-oriented programming (OOP) approach is very much useful while designing and maintaining software programs. Object-oriented programming (OOP) is a basic programming paradigm that almost every developer has used at some stage in their career.
Constructor
The easiest way to think of a constructor in object-oriented programming (OOP) languages is:
Create an application named SalesTransactiobDemo that declares several SalesTransaction objects and displays their values and their sum.
Name - The salesperson name (as a string)
sales Amount- The sales amount (as a double)
commission- The commission (as a double)
RATE- A readonly field that stores the commission rate (as a double). Define a getRate() avcessor method that returns the RATE
Include 3 constructors for the class. One constructor accepts values for the name, sales amount, and rate, and when the sales value is set, the constructor computes the commission as sales value times commission rate.
The second constructor accepts a name and sales amount, but sets the commission rate to 0
The third constructor accepts a name and sets all the other fields to 0
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images