Está en la página 1de 16

TUGAS RUTIN

ALGORITMA DAN PEMROGRAMAN

KELOMPOK 1

NAMA MAHASISWA : DICKY ANTONI PANJAITAN. (4172121020)

LISA SONIA HUTAJULU (4172121026)

NUR HASANAH (4173321037)

KELAS : FISIKA DIK C 2017

DOSEN PENGAMPU : Prof. Dr. SAHYAR, M.S., M.M.

PROGRAM STUDI S1 PENDIDIKAN FISIKA

FAKULTAS MATEMATIKA DAN ILMU PENGETAHUAN ALAM

UNIVERSITAS NEGERI MEDAN

MEDAN

SEPTEMBER 2019
1. Rancang Program Komputer untuk menentukan nilai P dari rumusan berikut, jika nilai a,b,c
𝑎
dan d diketahui : 𝑃 = 𝑎 + 𝑏 2 + 𝑏+𝑑
Jawab :
1) Problem Definition
a
 Determine the value of P from the formula P  a  b 2 
bd
 Input koef : a, b, c,d
 Output : value of P

2) Data Structure
Unit Variable Type of Data Description
Coefficient a a Real/Numeric Input data
Coefficient b b Real/Numeric Input data
Coefficient c c Real/Numeric Input data
Coefficient d d Real/Numeric Input data
Value of P P Real/Numeric Output data

3) Algorithm Program
a. Start
b. Input data
Input a
Input b
Input c
c. Process
x  b+d;
if x~=0 then
P  a+b^2+(a/x);
else x==0
P  a+b^2+(a/x);
end
d. Output data
if x~=0
write ('The value of P is definite');
write(P);
else x==0
write('The value of P is infinite');
write(P);
end
e. Stop

4) Coding in MatLab

%data input
clc;
a=input(' Coef a= ');
b=input(' Coef b= ');
c=input(' Coef c= ');
d=input(' Coef d= ');
%process
x=b+d;
if x~=0
P=a+b^2+(a/x);
else x=0
P=a+b^2+(a/x);
end
%Output
if x~=0
disp('The value of P is definite');
fprintf('P =%5.2f \n',P);
else x=0
disp('The value of P is infinite');
fprintf('P =%5.2f \n',P);
end

5) Testing Program
a) Coef a= 3
Coef b= 2
Coef c= 1
Coef d= -2
x=0
The value of P is infinite
P = Inf

b) Coef a= 2
Coef b= 3
Coef c= 1
Coef d= 1
The value of P is definite
P =11.50

c) Coef a= 3
Coef b= -4
Coef c= 1
Coef d= 4
x=0
The value of P is infinite
P = Inf
2. Rancang Program komputer untuk menentukan nilai P dari rumusan berikut, jika nilai a,b,c,
𝑐 𝑎
dan d diketahui : 𝑃 = 𝑏 2 + 𝑏+𝑑 + 𝑑
Jawab :

Problem Definition
c a
 Determine the value of P from the formula P  b 2  
bd d
 Input koef : a, b, c,d
 Output : value of P

1) Data Structure
Unit Variable Type of Data Description
Coefficient a a Real/Numeric Input data
Coefficient b b Real/Numeric Input data
Coefficient c c Real/Numeric Input data
Coefficient d d Real/Numeric Input data
Value of P P Real/Numeric Output data

2) Algorithm Program
f. Start
g. Input data
Input a
Input b
Input c
h. Process
x  b+d;
if x~=0 then
P  b^2+(c/x)+(a/d);
else x==0
P  b^2+(c/x)+(a/d);
end
i. Output data
if x~=0
write ('The value of P is definite');
write(P);
else x==0
write('The value of P is infinite');
write(P);
end
j. Stop

3) Coding in MatLab

%data input
clc;
a=input(' Coef a= ');
b=input(' Coef b= ');
c=input(' Coef c= ');
d=input(' Coef d= ');
%process
x=b+d;
if x~=0
P=b^2+(c/x)+(a/d);
else x=0
P=b^2+(c/x)+(a/d);
end
%Output
if x~=0
disp('The value of P is definite');
fprintf('P =%5.2f \n',P);
else x=0
disp('The value of P is infinite');
fprintf('P =%5.2f \n',P);
end

4) Testing Program
a) Coef a= 1
Coef b= 2
Coef c= 3
Coef d= 4
The value of P is definite
P = 4.75

b) Coef a= 4
Coef b= -10
Coef c= 10
Coef d= 10
x=0
The value of P is infinite
P = Inf

c) Coef a= 7
Coef b= 14
Coef c= 3
Coef d= 2
The value of P is definite
P =199.69

3. Rancang Program komputer untuk menentukan nilai P dari rumusan berikut, jika nilai a,b,c,
dan d diketahui : 𝑃 = 𝑎 + 𝑏 2 + √𝑐 − 𝑑
Jawab :

Problem Definition

 Determine the value of P from the formula P  a  b 2  c  d


 Input koef : a, b, c,d
 Output : value of P

1) Data Structure
Unit Variable Type of Data Description
Coefficient a a Real/Numeric Input data
Coefficient b b Real/Numeric Input data
Coefficient c c Real/Numeric Input data
Coefficient d d Real/Numeric Input data
Value of P P Real/Numeric Output data

2) Algorithm Program
a. Start
b. Input data
Input a
Input b
Input c
c. Process
x  c-d;
if x>0 then
P  a+b^2+ sqrt(x);
Elseif x=0
P  a+b^2+ sqrt(x);
else
P  a+b^2+ sqrt(x);
end
d. Output data
if x>0
write ('The value of P is definite');
write(P);
elseif x=0
write('The value of P is definite');
write(P);
else
write('The value of P is infinite');
write(P);
end if
e. Stop

3) Coding in MatLab

%data input
clc;
a=input(' Coef a= ');
b=input(' Coef b= ');
c=input(' Coef c= ');
d=input(' Coef d= ');
%process
x=c-d;
if x>0
P=a+b^2+ sqrt(x);
elseif x==0
P=a+b^2+ sqrt(x);
else
Pc=a+b^2+ sqrt(x);
end
%Output
if x>0
disp('The value of P is definite');
fprintf('P =%5.2f \n',P);
elseif x==0
disp('The value of P is definite');
fprintf('P =%5.2f \n',P);
else
disp('The value of P is complex');
fprintf('P =%5.2f \n',P);disp(Pc);
end

4) Testing Program
a) Coef a= 1
Coef b= 2
Coef c= 4
Coef d= 3
The value of P is definite
P = 6.00

b) Coef a= 3
Coef b= 5
Coef c= 7
Coef d= 9
The value of P is complex
P =28.00
28.0000 + 1.4142i

c) Coef a= 7
Coef b= 14
Coef c= 3
Coef d= 2
The value of P is definite
P =204.00

4. Rancang Program komputer untuk menentukan besarnya gaya coulomb dari dua muatan
dengan jarak r jika besar kedua muatan dan r diketahui.
Jawab :
1) Problem Definition
k.q1 .q 2
 Determine the value of P from the formula F 
r2
 Input koef : k, q1, q2, r
 Output : value of F

2) Data Structure
Unit Variable Type of Data Description
K k Real/Numeric Input data
Muatan 1 q1 Real/Numeric Input data
Muatan 2 q2 Real/Numeric Input data
Distance r Real/Numeric Input data
Value of F F Real/Numeric Output data

3) Algorithm Program
a. Start
b. Input data
Input k
Input q1
Input q2
Input r
c. Process
x  r;
if x>0 then
F  k*q1*q2/(x^2);
end
d. Output data
if x>0
write ('The value of F');
write(F);
end if
e. Stop

4) Coding in MatLab
%data input
clc;
k=input(' k= ');
q1=input(' q1= ');
q2=input(' q2= ');
r=input(' r= ');
%process
x=r;
if x>0
F=k*q1*q2/(x^2);
end
%Output
if x>0
disp('The value of F');
fprintf('F =%5.2f \n',F); disp(['N']);
end

5) Testing Program
a) k= 9*(10^9)
q1= 2
q2= 3
r= 4
The value of F
F =3375000000.00 N
b) k= 9*(10^9)
q1= 6
q2= 8
r= 2
The value of F
F =108000000000.00 N
c) k= 9*(10^9)
q1= 1
q2= 10
r= 10
The value of F
F =900000000.00 N
5. Rancang Program komputer untuk menentukan besarnya kuat medan listrik dan potensial
listrik oleh muatan pada jarak tertentu, jika besar muatan dan jarak diketahui .
Jawab :

Problem Definition

k .q
 Determine the value of P from the formula E 
r2
 Input koef : k, q, r
 Output : value of E

1) Data Structure
Unit Variable Type of Data Description
K k Real/Numeric Input data
Muatan q Real/Numeric Input data
Distance r Real/Numeric Input data
Value of E E Real/Numeric Output data

2) Algorithm Program
a. Start
b. Input data
Input k
Input q
Input r
c. Process
x  r;
if x>0 then
E  k*q/(x^2);
end
d. Output data
if x>0
write ('The value of E');
write(E);
end if
e. Stop

3) Coding in MatLab

%data input
clc;
k=input(' k= ');
q=input(' q= ');
r=input(' r= ');
%process
x=r;
if x>0
E=k*q/(x^2);
end
%Output
if x>0
disp('The value of E');
fprintf('E =%5.2f \n',E); disp(['N/C']);
end

4) Testing Program
a) k= 9*(10^9)
q= 2
r= 3
The value of E
E =2000000000.00 N/C

b) k= 9*(10^2)
q= 3
r= 4
The value of E
E =168.75 N/C

c) k= 9*(10^9)
q= 5
r= 10
The value of E
E =450000000.00 N/C

También podría gustarte