% Name: Song Yiheng % ID: 29275873 % Date Created: Aug 23 %% Lab 4 Task1 % Prompt User To Input The Shape They Want To Choose
% Name: Song Yiheng % ID: 29275873 % Date Created: Aug 23 %% Lab 4 Task1 % Prompt User To Input The Shape They Want To Choose
% Name: Song Yiheng % ID: 29275873 % Date Created: Aug 23 %% Lab 4 Task1 % Prompt User To Input The Shape They Want To Choose
% ID: 29275873
% Date created: Aug 23
clear all; clear all; clc;
%% Lab 4 Task1
% prompt user to input the shape they want to
choose
fprintf('Shapes(ID Number):
\n1.Square\n2.Rectangle\n3.Circle\n----------------
--------\n')
shape = input('Input the wanted shape(ID
Number):');
% Square
if shape == 1
square_sidelength = input ('Enter the side
length of the square:');
square_area = square_sidelength *
square_sidelength;
fprintf('--------\nThe area of the square
is %.2f',square_area)
% Rectangle shape
elseif shape == 2
rectangle_width = input('Enter the width of the
rectangle:')
rectangle_height = input('Enter the height of
the rectangle:')
rectangle_area = rectangle_width *
rectangle_height;
fprintf('--------\nThe area of the rectangle
is %.2f', rectangle_area)
elseif shape == 3
circle_radii = input('Enter the radii of the
circle:')
circle_area = pi*cicle_radii*circle_radii;
fprintf('--------\nThe area of the circle
is %.2f', circle_area)
end
function n_fac = stirling_appro(n)
n_fac = (sqrt(2*pi*n))*((n/exp(1))^n);
%If Statement
if mod(nfac_round,2)==0 && mod(nfac_round,3)~=0 &&
mod(nfac_round,7)~=0
nfac_str = 'divisible by 2 only but not
divisible by 3 and 7';
elseif mod(nfac_round,3)==0 && mod(nfac_round,2)~=0
&& mod(nfac_round,7)~=0
nfac_str = 'divisible by 3 only but not
divisible by 2 and 7';
elseif mod(nfac_round,7)==0 && mod(nfac_round,3)~=0
&& mod(nfac_round,2)~=0
nfac_str = 'divisible by 7 only but not
divisible by 2 and 3';
elseif mod(nfac_round,2)==0 && mod(nfac_round,3)==0
&& mod(nfac_round,7)~=0
nfac_str = 'divisible by 2 and 3 but not
divisible by 7';
elseif mod(nfac_round,2)==0 && mod(nfac_round,7)==0
&& mod(nfac_round,3)~=0
nfac_str = 'divisible by 2 and 7 but not
divisible by 3';
elseif mod(nfac_round,3)==0 && mod(nfac_round,7)==0
&& mod(nfac_round,2)~=0
nfac_str = 'divisible by 3 and 7 but not
divisible by 2';
elseif mod(nfac_round,2)==0 && mod(nfac_round,3)==0
&& mod(nfac_round,7)==0
nfac_str = 'divisible by 2,3 and 7';
elseif mod(nfac_round,3)~=0 && mod(nfac_round,2)~=0
&& mod(nfac_round,7)~=0
nfac_str = 'not divisble by 2, 3 and 7';
end
filename='BSA.txt';
file_id=fopen(filename,'W');
fprintf(file_id,'BSA value of each person\n');
fprintf(file_id,'%10s %10s %10s %10s\n','Person#','
Mass(kg)','Height(m)','BSA');
fprintf(file_id,'%10.2f %10.2f %10.2f %10.2f\n',[P'
W' H' BSA']');
fclose(file_id);
% Name: Song Yiheng
% ID: 29275873
% Date created: Aug 23
clear all; clear all; clc;
%% Lab 4 Task 5
% Import the data
X = importdata('ENG1060studentmarks.txt');
num_data = X.data;
ID = num_data(:,1);
lab_mark = num_data(:,2:11);
assignment1 = num_data (:,12);
lab = sum(lab_mark')/10*2;
assignment = assignment1';