Calculate Sales Tax
Learn about modules and mixin in Ruby.
Problem
The sales tax in Australia is called the goods and services tax (GST) of 10%, which is applied to most products and services. For example, in a physio clinic, medical services such as physiotherapy are GST-free. However, GST applies to pilates classes (also a service), and also to all products sold at the clinic. All businesses must show GST-inclusive prices. For example, for a $10 meal, $9.09 is the net amount and $0.91 is sales tax.
Write a program below that defines the Goods
and ServiceItem
classes. Ensure that objects of both types can invoke the methods, net_amount
and gst
, to calculate the net amount and sales tax of products and services.
Expected Output
We can test the class definitions you provide with code as shown below:
Get hands-on with 1400+ tech skills courses.