At Westonci.ca, we provide clear, reliable answers to all your questions. Join our vibrant community and get the solutions you need. Join our Q&A platform to connect with experts dedicated to providing precise answers to your questions in different areas. Connect with a community of professionals ready to help you find accurate solutions to your questions quickly and efficiently.
Sagot :
Answer:
Explanation:
The following code is all written in Java, first I will add the object initialization and declaration code that can be added to the main method of any program. Then I have also written the entire SalesTransaction class as the question was not clear as to exactly which was needed.
//Object Creation to copy and paste into main method
SalesTransaction sale1 = new SalesTransaction("Gabriel", 25, 5);
SalesTransaction sale2 = new SalesTransaction("Daniela", 5);
SalesTransaction sale3 = new SalesTransaction("Jorge");
//SalesTransaction class with three constructors
package sample;
class SalesTransaction {
String name;
int salesAmount, commission;
private int commissionRate;
public SalesTransaction(String name, int salesAmount, int rate) {
this.name = name;
this.salesAmount = salesAmount;
this.commissionRate = rate;
commission = salesAmount * rate;
}
public SalesTransaction(String name, int salesAmount) {
this.name = name;
this.salesAmount = salesAmount;
this.commissionRate = 0;
}
public SalesTransaction(String name) {
this.name = name;
this.salesAmount = 0;
this.commissionRate = 0;
}
}
Thanks for using our platform. We're always here to provide accurate and up-to-date answers to all your queries. We appreciate your time. Please revisit us for more reliable answers to any questions you may have. Discover more at Westonci.ca. Return for the latest expert answers and updates on various topics.