76 967
Assignments Done
Successfully Done
In June 2019

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() {

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

publicdouble getValue() {

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

publicint getQuantity() {

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

publicdouble getPrice() {

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

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

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!


No comments. Be first!

Leave a comment

Ask Your question

Privacy policy Terms and Conditions