Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a Java class definition for the Product class with the following features: Instance variables : productName for the Product name of type String. productPrice

Write a Java class definition for the Product class with the following features: Instance variables : productName for the Product name of type String. productPrice for the Products price of type double. Constructor: public Product (String pName, double pPrice): A constructor without parameters public Product (String pName, double pPrice): A constructor with parameters, it creates the Product object by setting the two fields to the passed values. Instance methods: public void setProductName (String productName): Used to set the name of product. public void setProductPrice(double productPrice): Used to set the price of product. public double getProuctName(): This method returns the name of the product. public double getProductPrice(): This method returns the price of the product. public String toString(): This method prints the products name and price to the screen Write a separate class ProductDemo with a main() method that creates a Product titled Monitor with Price $1200.00 and prints the products string representation to the standard output.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Harness The Power Of Big Data The IBM Big Data Platform

Authors: Paul Zikopoulos, David Corrigan James Giles Thomas Deutsch Krishnan Parasuraman Dirk DeRoos Paul Zikopoulos

1st Edition

0071808183, 9780071808187

More Books

Students also viewed these Databases questions