Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

python Exercise Write a program that creates a simple class definition for a Product object The class should use the __init()__ constructor method to receive

python

Exercise

Write a program that creates a simple class definition for a "Product" object

The class should use the __init()__ constructor method to receive three bits of information about the product as the object is created - (name, price, and discountPercent)

The class should contain two methods. One for returning the Discount Amount and the other for returning a Discounted Price

Inside the same .py file as your new Product class, write code to create two separate instances of a "product". Note: You can either hard-code the parameter values or you can prompt the user for input. Either is fine

Print the product information to the screen. You will access both arguments and methods to get the correct output.

HINTS:

Use the "self" parameter in you methods as seen in book examples or other references.

The Discount Amount can be determined by dividing the discountPercent argument by 100 and multiplying that by the price

The Discounted Price can be calculated by subtracting the Discounted Amount from the price. Note call the above Discount Amount method from inside this method to use in your calculation rather than doing the above formula again.

# This is an example of how the output should appear for a product once your code has run; assuming you coded these values. PRODUCT DATA Name: Stanley 13 Ounce Wood Hammer Price: $12.99 Discount percent: 62% Discount amount: $8.05 Discount price: $4.90

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

Step: 3

blur-text-image

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

Concepts Of Database Management

Authors: Philip J. Pratt, Joseph J. Adamski

4th Edition

ISBN: 0619064625, 978-0619064624

Students also viewed these Databases questions