Upcoming SlideShare
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Standard text messaging rates apply

Laporan praktikum alpro

448

Published on

0 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

• Be the first to like this

Views
Total Views
448
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
4
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript

• 1. POLITEKNIK CALTEX RIAU1 SI ALAPORAN PRAKTIKUM ALGORITMADAN PEMROGRAMANPRAKTIKUM 1.2.3.4ERHAN ARDIANDAROHADATUL AISY
• 2. Praktikum 1 :/** To change this template, choose Tools | Templates* and open the template in the editor.*/package Latihan;/**** @author compaq*/public class DemoVariabel {public static void main(String[] args) {//contoh bilangan bulat/integerbyte aByte =120;short aShort = 255;int anInteger = 4500;long aLong = 56789l;//contoh bilangan realfloat aFloat = 87.36f;double aDouble = 87.363D;//tipe primitif lainnyachar aChar = S;boolean aBoolean = true;System.out.println("aByte berisi"+aByte);System.out.println("aShort berisi"+aShort);System.out.println("anInteger berisi"+anInteger );System.out.println("aLong berisi"+aLong);System.out.println("aFloat berisi" +aFloat);System.out.println("aDouble berisi"+aDouble);System.out.println("aChar berisi"+aChar);System.out.println("aBoolean berisi"+aBoolean);}}
• 3. Maka hasilnya akan seperti ini :aByte berisi120aShort berisi255anInteger berisi4500aLong berisi56789aFloat berisi87.36aDouble berisi87.363aChar berisiSaBoolean berisitrueBUILD SUCCESSFUL (total time: 1 second)Praktikum 2/** To change this template, choose Tools | Templates* and open the template in the editor.*/package Latihan;/**** @author compaq*/public class DemoAritmetika {private static int aLong;public static void main(String[] args) {short aShort = 20;int anInteger = 401;long along= 450L;float aFloat = 90;System.out.println("aLong="+along);System.out.println("anInteger="+anInteger);long otherLong = aLong+anInteger;System.out.println("otherLong setelah operasi aLong +anInteger adalah1 "+otherLong);System.out.println("aFloat="+aFloat);
• 4. System.out.println("anShort="+aShort);float otherFloat =aFloat/aShort;System.out.println("otherFloat = aFloat/aShort adalah"+otherFloat);System.out.println("anInteger=");anInteger = anInteger/4;System.out.println("anInteger setelah anInteger = anInteger/4 adalah "+anInteger);int x = anInteger++;System.out.println("Setelah operasi x =anInteger++maka nilai untuk ");System.out.println("anInteger="+anInteger);System.out.println("dan x="+x);x = ++anInteger;System.out.println("Setelah operasi x=++anInteger maka nilai untuk");System.out.println("anInteger="+anInteger);System.out.println("dan x=");}}Maka hasilnya akan seperti ini :anInteger=anInteger setelah anInteger = anInteger/4 adalah 100Setelah operasi x =anInteger++maka nilai untukanInteger=101dan x=100Setelah operasi x=++anInteger maka nilai untukanInteger=102dan x=BUILD SUCCESSFUL (total time: 0 seconds)
• 5. Praktikum 3/** To change this template, choose Tools | Templates* and open the template in the editor.*/package Latihan;/**** @author compaq*/public class RelationalDemo {public static void main(String[] args) {int i=37;int j = 42;int k = 42;System.out.println("Nilai variabel...");System.out.println("i="+i);System.out.println("j="+j);System.out.println("k="+k);System.out.println("Lebih besar dari ...");System.out.println("i&gt;j="+(i&gt;j));System.out.println("j&gt;i="+(j&gt;i));System.out.println("k&gt;j="+(k&gt;j));System.out.println("Lebih besar atau sama dengan ...");System.out.println("i&gt;=j="+(i&gt;=j));System.out.println("j&gt;=i="+(j&gt;i));System.out.println("k&gt;=j="+(k&gt;j));System.out.println("Lebih kecil dari...");System.out.println("i&lt;j="+(i&lt;j));System.out.println("j&lt;i="+(j&lt;i));System.out.println("k&lt;j="+(k&lt;j));System.out.println("Lebih kecil dari atu sama dengan ...");System.out.println("i&lt;=j"+(i&lt;=j));
• 6. System.out.println("j&lt;=i"+(j&lt;=i));System.out.println("k&lt;=j"+(k&lt;=j));System.out.println("Sama dengankah...");System.out.println("i==j"+(i==j));System.out.println("k==j"+(k==j));System.out.println("Tidak sama dengankah...");System.out.println("i!=j="+(i!=j));System.out.println("k!=j="+(k!=j));}}Maka hasilnya akan seperti ini :j&lt;=ifalsek&lt;=jtrueSama dengankah...i==jfalsek==jtrueTidak sama dengankah...i!=j=truek!=j=falseBUILD SUCCESSFUL (total time: 0 seconds)Praktikum 4/** To change this template, choose Tools | Templates* and open the template in the editor.*/package Latihan;/**** @author compaq*/
• 7. public class DemoIfSingkat {public static void main(String[] args) {int inputV1=5;int inputV2=2;int digital;digital = inputV1&gt;2.5?1:0;System.out.println("Digital dari V1:"+digital);digital = inputV2&gt;2.5? 1:0;System.out.println("Digital dari V2:"+digital);}}Hasilnya akan seperti ini :run:Digital dari V1:1Digital dari V2:0BUILD SUCCESSFUL (total time: 0 seconds)