Skip to main content

Book Sale Discount

Book Sale Discount

Challenge: Jonny wants to purchase three books with prices of $15.08, $50.88, and $150.96. Each book comes with two coupon options, either $5 off or 5% off. The object of the activity is to create an algorithm that helps Jonny compare the discounts and determine the most cost-effective choice. Code the VR Robot to drive around the Art Canvas +playground to “click” the coupon buttons under each book to indicate which coupon to use and calculate the total cost of the three books using selected coupons. To “click” a button, use the VR Pen to fill the button area with green. 

  • Choose and Download the Book Sale Discount worksheet as a PNG file from this Google slideshow.
  • Select the Art Canvas+ Playground and upload the Book Sale Discount worksheet.
  • Design an algorithm to calculate the discount and select the coupon for each book.
    • Create variables to represent the total cost of the three books, the cost of each book, and the discount using coupons.
    • Create an expression to calculate the discounts of each book using different coupons, and compare the discounts to select the coupon to use. 
    • Use the VR Pen to fill the selected coupon button with green.
    • Create an expression to calculate the cost of each book using the selected coupon.
  • Create an expression to calculate the total cost of the three books using the selected coupons. Use the [print] block to print the calculated value to the Print Console.

Helpful Hints

  • Create a My Block with one parameter to select a coupon based on the book price to make the project shorter and more easily readable.VEXcode My blocks Definition block that reads 'define CouponSelection' with a numerical parameter that reads 'price'.
    • Matching Python command:

      def CouponSelection(price):