Lab1COS10009 Week1
Lab1COS10009 Week1
2
Name: Le Thanh Nam
Student ID: 104999380
Pseudocode:
Read the value of appetizer_price
Read the value of main_price
Read the value of dessert_price
total_price = appetizer_price + main_price +
dessert_price
Print ‘$’ then the value of total_price to the terminal
showing two decimal places.
Test Data:
First data Second data
set set
appetizer_p 10.30 12.40
rice
main_price 34.00 41.00
dessert_pric 8.50 9.80
e
Expected Result:
Now check the actual code produces the output you expected
Do this by completing the missing code in bill_total.rb in Task 1.3 then running the
program.
3. Short Answer Questions:
Here are some terms that may help you: Assignment, evaluate, increment,
Data Type
· Local Scope: Variables defined within a method, block, or class have local scope. They
are only accessible within that specific context and are destroyed when the context ends.
· Global Scope: Variables defined outside of any method, block, or class have global scope.
They can be accessed from anywhere within the program, including within methods, blocks,
and classes.
See the lesson materials for help with Question 6. You could also see:
https://www.tutorialspoint.com/ruby/ruby_variables.htm