G Parabola: 'Masukan Jumlah Angka ' 'Masukan Angka '

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 8

Masukkan input angka

clc;clear;
n=input('masukan jumlah angka = ');
for i=1:1:n
x(i)=input('masukan angka = ');
end
fprintf('\n')
fprintf('\n')
disp(x)

G Parabola
clc;clear;
Vo=input('Vo = ');
Xo=input('Xo = ');
Yo=input('Yo = ');
Xt=input('Xt = ');
Yt=input('Yt = ');
Ht=input('Ht = ');
a=input('a = ');
t=(Xt-Xo)/Vo/cos(degtorad(a));
yot=Yo+Vo*sin(degtorad(a))*t-10*(t^2)/2;
if yot>= Yt-Ht/2 && yot<=Yt+Ht/2
fprintf('target kena\n')
else
fprintf('miss\n')
end
tplot=0:0.001:t;
yplot=Yo+Vo*sin(degtorad(a))*tplot-10*(tplot.^2)/2;
plot(tplot,yplot); hold on
yy=Yt+Ht;
yyy=Yt:0.0001:yy;
plot(Xt,yyy,'r');
hold off
%program ini mengurutkan ulang array yang
%diinput mulai dari yang selisihnya terkecil
%dari rata-rata data dalam array tsb
%contoh:
%input [1 2 3 4 5]
%output [3 2 4 1 5]
clc;clear;
data=input('inputkan array= ');
rata2=mean(data)
selisih=abs(data-rata2)
for i=1:length(data)-1
for j=i+1:length(data)
if selisih(i)>selisih(j)
a=data(i);
b=data(j);
data(i)=b;data(j)=a;
c=selisih(i);

d=selisih(j);
selisih(i)=d;selisih(j)=c;
end

end

end
data

Write File
a=input('Nama file input(termasuk.txt) :','s');
[x,y,z]=textread(a,'%d %d %d',4,'headerlines',2);
v=x.*y.*z;
l=2*(x.*y+x.*z+y.*z);
r=4*(x+y+z);
b=input('nama file output(termasuk.txt) :','s');
c=fopen(b,'w');
fprintf(c,'data hasil perhitungan\n');
fprintf(c,'R(cm) L(cm2 ) V(cm3)\n');
for i=1:length(x)
fprintf(c,'%5.2f %6.2f %6.2f\n',r(i),l(i),v(i));
end
fclose(c);
Bakso
clear;clc;
i=0;
total=0;
nilai=0;
while nilai~=9999
i=i+1;
nilai=input('nilai data = ');
total = nilai + total;
end
total = total - 9999;
i=i-1
rata=total/i;
fprintf('\n')
fprintf('total nilai = %d\n',total)
fprintf('jumlah data = %d\n',i)
fprintf('rata-rata data = %d\n',rata)

Selang seling print


for i = 5:-1:1
for j = i:-1:1
if mod (i , 2)==0
fprintf('#')
else
fprintf('*')
end
end
fprintf ('\n')
end

FPB KPK
a=input('masukan angka: ');
b=input('masukan angka: ');
c=gcd(a,b);
d=lcm(a,b);
fprintf('fpb= %d\n',c)
fprintf('kpk= %d\n',d)

clc;clear;
a=input('a= ');
b=input('b= ');
i=1;
while mod(a*i,b)~=0
i=i+1;
end
kpk=a*i
%cari fpb
if a<b
c=a;
else
c=b;
end
for i=1:c
if mod(a,i)==0 & mod(b,i)==0
fpb=i;
end
end
fpb
clc;clear;
fprintf('Guessing Games 1-100\nWith 15 Chance to Guess the correct Number\n');
Chance=15;
Turn=1;
Score=100;
%rn=Real Number;
rn=rand(1);
rn=100*rn;
rn=ceil(rn);
fprintf('I am Thinking a Number between 1 to 100\n');
guess=input('Guess that Number : ');
while guess~=rn
Distance=abs(guess-rn);
if Distance>50
fprintf('Your Guess is Too Far\n');
elseif Distance>30
fprintf('Your Guess is Still Far\n');
elseif Distance>15
fprintf('Your Guess is Not to Far\n');
elseif Distance>10
fprintf('Your Guess is Nearly Close\n');
elseif Distance>5
fprintf('Your Guess is Almost Close\n');

elseif Distance>=1
fprintf('Your Guess is Very Close\n');
end
Chance=Chance-1;
fprintf('Your Chances Left : %d\n',Chance);
if Chance==0
break
end
Turn=Turn+1;
guess=input('Guess Another Number : ');
fprintf('\n');
if Chance<=10
Score=Score-10;
end
end
if Chance==0
fprintf('You Failed.. Please Try Again\n');
fprintf('Your Score is %d',Score);
else
fprintf('Congratulations! You guessed the Correct Number in %d Turn and
Still Have %d Chances \n',Turn,Chance);
fprintf('Your Score is %d\n',Score);

INDLG
clear;clc;lagi=1;
prompt={'b (mm)','h (mm)'};
dlgTitle='INPUT DATA';
def={'300','400'};
lineNo=1;
lagi=1;
while lagi==1
answer=inputdlg(prompt,dlgTitle,lineNo,def);
data=str2num(char(answer));
b=data(1)
h=data(2)
A=b*h
def={num2str(data(1)),num2str(data(2))};
lagi=input('input lagi? [1]ya [0]tidak :');
end
clear;clc;
for a1=123:329
a2=2*a1;
a3=3*a1;
astr=[num2str(a1),num2str(a2),num2str(a3)];
for i=1:9
A(i)=str2num(astr(i));
end
status=1;
for i=1:8
for j=i+1:9

if A(i)*A(j)==0 || A(i)==A(j)
status=0;
end
end
if status==0
break;
end

end

end
if status==1
A
end

%Studio Bahasa Pemrograman


%Praktikum 5
%Richard Antoni Gosno / Nrp :21413042
clc;clear;
x=[0 4 7 2 -2 -5 -8 -2 0];
y=[0 -1 5 10 4 2 -1 -2 0];
plot(x,y,'m--')
title('Daerah Galian');
hold on
fill(x,y,'y');
clc;clear;
x=[0 4 7 2 -2 -5 -8 -2 0];y=[0 -1 5 10 4 2 -1 -2 0];
title('Daerah Galian')
grid on
plot(x,y,'m')
hold on
fill(x,y,'y')
text(0,0,'A');
text(4,-1,'B');
text(7,5,'C');
text(2,10,'D')
text(-2,4,'E');
text(-5,2,'F');
text(-8,-1,'G');
text(-2,-2,'H');
text(0,0,'I');
clear;clc;
x=-1:0.01:1;
eq1=(8.*x + 12)./7;
eq2=-29.*(x.^2) + 2.*(x) + 17;
plot(x,eq1,'b--',x,eq2,'r')
xlabel('Absis')
ylabel('Ordinat')
legend('7y=8x + 12','29(x^2) - 2x + y - 17=0')
solve('29*x^2-2*x+(8*x+12)/7-17=0','x');
x1=3/203 - 21730^(1/2)/203;
x2=21730^(1/2)/203 + 3/203;
y1=(8/7)*x1 + 12/7;
y2=(8/7)*x2 + 12/7;

text(x1,y1,'Tipot 1')
text(x2,y2,'Tipot 2')

%Studio Bahasa Pemrograman


%Praktikum 7
%Richard Antoni Gosno / Nrp :21413042
clc;clear;
fprintf('------------------------------------\n');
fprintf('Lengkapilah Formulir Berikut:\n');
fprintf('------------------------------------\n');
email=input('E-Mail
: ','s');
password=input('Password
: ','s');
fprintf('------------------------------------\n');
clc;
for i=1:length(email)
if email(i)=='@'
a=i;
user=email(1:a-1);
end
end
disp('-----------------------------------');
fprintf('Username
: %s\n',user);
n=input('Konfirmasi : ','s');
if length(n)==length(password)
if n==password
disp('Konfirmasi Berhasil');
else
disp('Konfirmasi Gagal');
end
else
disp('Konfirmasi Gagal');
end
disp('-----------------------------------');

%Studio Bahasa Pemrograman


%Praktikum 8
%Richard Antoni Gosno / Nrp :21413042
%1
clc;clear;
p=input('Masukkan Panjang Batang (m): ');
b=input('Masukkan Beban Terpusat(ton) :');
l=input('Masukkan Jarak Beban Dari Kiri(m) : ');
d1=b*(p-l)/p;tb=b;d2=tb-d1;N=0;j=(d1*p)/(d1+d2);M=d1*j;
fprintf('N = %d t\n',N)
fprintf('Dkiri = %d t\n',d1)
fprintf('Dkanan = %d t\n',d2)

fprintf('M = %d t\n',M)
x=input('Masukan Jarak Potong = ');
if x>l
Nx=0;
Da=(b*(x-l))/x;
Dx=b-Da;
Mx=(Da*x)-b*(x-l);
fprintf('Nx = %d t\n',Nx)
fprintf('Dx = %d t\n',Dx)
fprintf('Mx = %d t\n',Mx)
end
Nx=0;
Dx=(b*((p-x)-(l-x))/(p-x));
Dka=b-Dx;
Mx=Dka*(p-x)-Dx*(l-x);
fprintf('Nx = %d t\n',Nx)
fprintf('Dx = %d t\n',Dx)
fprintf('Mx = %d t\n',Mx)
%2
clear;clc;
fprintf('Keterangan: a^b=c atau alogc=b\n')
a=input('a=');
c=input('c=');
format short
b= (log (c))/(log (a))
%Studio Bahasa Pemrograman
%Praktikum 9
%Richard Antoni Gosno / Nrp :21413042
clc;clear;
datafile=input('Masukkan Nama File (Including .txt) : ','s');
[l w h tf tw]=textread(datafile,'%d %d %d %d %d',7,'headerlines',2);
for i=1:length(l)
l(i)=l(i)*1000;
w(i)=w(i)*1000;
h(i)=h(i)*1000;
tw(i)=tw(i)*10;
la(i)=l(i)-2*tw(i);
wa(i)=w(i)-2*tw(i);
ha(i)=h(i)-tf(i);
va(i)=(la(i)*wa(i)*ha(i))*10^-9;
vb(i)=((l(i)*w(i)*h(i))-va(i))*10^-9;
vt(i)=(10/100)*vb(i);

jk(i)=ceil((l(i)*w(i))+(2*l(i)*h(i))+(2*w(i)*h(i))+((l(i)*w(i))-(la(i)*wa(i)))
+(la(i)*wa(i))+(2*la(i)*ha(i))+(2*wa(i)*ha(i)))/90000;
end

outname=input('Masukkan Nama File (Including .txt) : ','s');


fout=fopen(outname,'w');
fprintf(fout,'Hasil Perhitungan Tandon Air\n');
fprintf(fout,'Va(m3)
Vb(m3)
Vt(mm3)
Keramik\n');
for i=1:length(l);
fprintf(fout,'%5.2f
%5.2f
%5.2f
%5.2f
\n',va(i),vb(i),vt(i),jk(i));
end
fclose(fout);
Data
l(m)
1
2
3
3
5
5
5

Tandon:
w(m) h(m) tf(mm)
1
1
5
1
1
6
1
1
7
2
1
8
2
2
10
3
2
11
4
3
15

tw(cm)
10
12
15
17
20
22
30

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy