You are on page 1of 2

Miranda, Pierre James D.

CS10-8L/A3
CS10-8L: Computer Programming Laboratory
Exercise #3: Variables, Scripts and Visualizations

ANSWERS
1.
a. area.m
Perimeter: 80.000000
Volume: 2062.500000
Underground Surface Area: 815.000000

Script:
l = input("Enter length: ");
w = input("Enter width: ");
sum=l+w;
prod=l*w;
ave = input("Enter average depth: ");

perimeter=2*sum;
volume=prod*ave;
USA=perimeter*ave+prod;

fprintf("Perimeter: %f\n",perimeter);
fprintf("Volume: %f\n",volume);
fprintf("Underground Surface Area: %f\n",USA);

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

Script:
A=[3 12 1; 12 0 2; 0 2 3];
B=[2.36; 5.26; 2.77];

E=inv(A)*B;

disp('cost of single apple: ');


disp(E(1));
disp('cost of single banana: ');
disp(E(2));
disp('cost of single cantaloupes: ');
disp(E(3));

Prepared by: Engr. Cheryl Mari M. Isip


Prepared date: March 2019
Miranda, Pierre James D. CS10-8L/A3
CS10-8L: Computer Programming Laboratory
Exercise #3: Variables, Scripts and Visualizations

c. temperature.m
Temperature in Fahrenheit: 98.6000
Script:
t=input('Enter temperature in Celcius: ');
f=((9*t/5)+32);
f

Prepared by: Engr. Cheryl Mari M. Isip


Prepared date: March 2019

You might also like