0% found this document useful (0 votes)
15 views2 pages

Programming Lab Exercise on Variables

This document contains the answers and scripts from a computer programming exercise involving variables, scripts, and visualizations. It includes 3 parts - calculating the perimeter, volume, and underground surface area of a rectangular prism; finding the cost of various fruits by solving a system of equations; and converting a temperature from Celsius to Fahrenheit. The scripts demonstrate using variables, arrays, and mathematical operations to perform calculations and display results.

Uploaded by

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

Programming Lab Exercise on Variables

This document contains the answers and scripts from a computer programming exercise involving variables, scripts, and visualizations. It includes 3 parts - calculating the perimeter, volume, and underground surface area of a rectangular prism; finding the cost of various fruits by solving a system of equations; and converting a temperature from Celsius to Fahrenheit. The scripts demonstrate using variables, arrays, and mathematical operations to perform calculations and display results.

Uploaded by

AJ Ortega
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

CS10-8L: Computer Programming Laboratory

Exercise #3: Variables, Scripts and Visualizations

Name: RECTO, LESTHER SAIRY A. Score:

Section: B23 Date: 12-13-


2020

ANSWERS
1.
a. area.m
Perimeter: 80
Volume: 2062.5/2.0625e+03
Underground Surface Area: 815

Script:
>>L=25;
>>W=15;
>>P=2*(L+W)

P =

80

>>L=25;
W=15;
A=5.5;
V=(L*W)*A

V =

2.0625e+03

>>LplusW=40;
>>A=5.5;
>>L=25;
>>W=15;
>>USA=2*LplusW*A+L*W

USA =

815

b. fruits.m
Cost of Banana: 0.2900
Cost of Apple: 0.0500

Prepared by: Engr. Cheryl Mari M. Isip


Prepared date: August 2020
CS10-8L: Computer Programming Laboratory
Exercise #3: Variables, Scripts and Visualizations

Cost of Cantaloupe: 0.8900

Script:
>>a=[3 12 1;12 0 2;0 2 3];
>>b=[2.36;5.26;2.77];
>>x=a\b

x =

0.2900
0.0500
0.8900

c. temperature.m
Temperature in Fahrenheit: 98.6000
Script:
>>C = 37;
F = C*9/5 + 32;
disp(F);

98.6000

Prepared by: Engr. Cheryl Mari M. Isip


Prepared date: August 2020

You might also like