64 542
Assignments Done
99,3%
Successfully Done
In September 2018

Answer to Question #17517 in Java | JSP | JSF for cord

Question #17517
Create a class named Product that contains private instance variables to hold the product's name, price, value, and quantity in stock. Create getters and setters that allow you to access and modify the name, price, value, and quantity of the product. Create a method named getProfit() to tell you the profit you would make if you sold one. The profit is the price less the value. Override the toString() method to return a string that contains the name of the product. Validation of the incoming data in the setters is not required.
Expert's answer
public class Product {
privateString name;
privatedouble price;
privatedouble value;
privateint quantity;

publicString getName() {
returnname;
}

publicvoid setName(String name) {
this.name = name;
}

publicdouble getValue() {
returnvalue;
}

publicvoid setValue(double value) {
this.value= value;
}

publicint getQuantity() {
returnquantity;
}

publicvoid setQuantity(int quantity) {
this.quantity= quantity;
}

publicdouble getPrice() {
returnprice;
}

publicvoid setPrice(double price) {
this.price= price;
}

publicdouble getProfit() {
returnthis.value - this.price;
}

@Override
publicString toString() {
return"Product name: " + name;
}

}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions