0% found this document useful (0 votes)
13 views7 pages

ENGG100 - Lab 2 Report

Lab 2 Report

Uploaded by

vanshika choube
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views7 pages

ENGG100 - Lab 2 Report

Lab 2 Report

Uploaded by

vanshika choube
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Task 1

Display “Hello World!” using various methods.

• Using the disp function:

• Using the msgbox function:

• Using helpdlg:

• Using GUI:

Page | 1
Task 2
Find the future value (FV) of a bank account starting with $1, 000 and with interest rate of 4% per
year, using the formula: 𝐹𝑉=𝑃𝑉(1+𝑟)𝑛. What will the value be in 10 years’ time?

Code:

Result:

Page | 2
Task 3

What is the surface area of a closed cylinder with height 30cm and radius 5cm: 𝑆𝐴=2𝜋𝑟2+2𝜋𝑟ℎ
Code:

Result:

Task 4
Calculate the distance between two points P1=(3,-3) and P2=(-5,3) using the formula:
𝑑=√(𝑥2−𝑥1)2+(𝑦2−𝑦1)2
Code:

Result:

Page | 3
Task 5
Using the Law of Cosines, the third side of a triangle with sides a, b and angle between them θ, is

𝑐=√𝑎2+𝑏2−2𝑎𝑏cos𝜃. Find the third side of a triangle with a=3, b=10 and θ=π/4.
Code:

Result:

Page | 4
Task 6
Demonstrate your ability to use proper commenting by writing a short program (a sequence of
steps) that performs the following tasks below.

• Set the initial values of the following variables: radius=3, height=10, density=8
• Calculate area = pi * radius^2
• Calculate volume = area * height
• Calculate mass = volume * density
Code:

Result:

Page | 5
Task 7
A phone costs $900 to buy outright. However, if you sign a two-year contract with
Telecommunications Company A, you can get the phone for $80 a month, with $500 monthly
credit. Telecommunications Company B offers a bring-your-own-phone plan at $20 a month for
the same amount of monthly credit. How much will you pay for each option over 2 years?
Code:

Result:

Page | 6
Task 8
Write a short program to convert from feet-and-inches to metres. Begin by requesting two inputs
from the user (feet, then inches) using the input function. Determine and implement an equation
for the conversion. Display the solution to the user using the disp function. Add a comment to
each line.
Code:

Result:

Page | 7

You might also like