011-002-004
Constructor Call: Product Class
Medium
Problem Description
constructor Call: Product class
In this problem, you will create a program that defines a Product class with a constructor, initializes an object with a product name and price, and displays the result to standard output.
Learning Objective
Learn how to call constructors to initialize objects.
Problem
Create a Product class with name and price, initialize via constructor.
Input
Line 1: Product name (string)
Line 2: Price (integer)
Output
Product: [name]
Price: [price]
Ready to Try Running Code?
Log in to access the code editor and execute your solutions for this problem.
Don't have an account?
Sign Up