Commit 742e585

mo khan <mo@mokhan.ca>
2022-12-15 18:27:32
complete an exercise from chapter two
1 parent ba0d6a3
Changed files (1)
assignments
assignments/1.md
@@ -23,6 +23,20 @@
    heavily as a regular test.
 4. Write an algorithm that gets the price for item A plus the quantity
    purchased. The algorithm prints the total cost, including 6% sales tax.
+
+    ```ruby
+    def calculate_total(price, quantity, tax = 0.06)
+      return (price * quantity) * (1.0 + tax)
+    end
+    ```
+
+    ```plaintext
+    Get values for `price` and `quantity`
+    Set the value of `tax` to 1.06
+    Set the vlue of `total` to `price` multiplied by `quantity` multiplied by `tax`
+    Return the value of `total`
+    ```
+
 5. Write an if/then/else primitive to do each of the following operations:
   * a. Compute and display the value `x / y` if the value of `y` is not `0`. if
     `y` does have the value `0`, then display the message `Unable to perform the