Created
October 10, 2017 05:39
-
-
Save dyazincahya/7f81cc87347f023188dd297eed5478b8 to your computer and use it in GitHub Desktop.
Tugas pemrogramman 3 semester 3 [1 - 4]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
96983749632949234689234932649236493289469236 | |
97938249732432432238497320949032430432048032 | |
23432432432214241948194708207210381300923801 | |
92479864912741970123821038021362137092832080 | |
92638238735497324937983209402374093280432048 | |
93274903270483204709380380480234032083204830 | |
92374023091730170301203018021380273074343293 | |
23423543657878985663453524325346478756856475 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* program array 2 dimensi | |
* | |
* @author (Cahya, Robi, Iqbal, Budi) | |
* @version (0.1 8/10/2017) | |
*/ | |
public class no1 | |
{ | |
public static void main(String [] args) | |
{ | |
// membuat isi elemen array | |
int [][] angka = { | |
{0, 1, 2, 3, 4}, | |
{5, 6, 7, 8, 9}, | |
{10, 11, 12, 13, 14}, | |
{15, 16, 17, 18, 19} | |
}; | |
int i, j; // i = baris v, j = kolom > | |
for (i=0;i<4;i++) | |
{ | |
for (j=0;j<5;j++) | |
{ | |
// menampilkan isi elemen baris dan kolom | |
System.out.print(angka[i][j]+" "); | |
} | |
System.out.println(""); | |
}//pindah baris | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* program substring | |
* | |
* @author (Cahya, Robi, Iqbal, Budi) | |
* @version (0.1 8/10/2017) | |
*/ | |
public class no2 | |
{ | |
public static void main(String [] args) | |
{ | |
String a = "Saya_adalah_String_a"; | |
/** | |
* Dua method substring tersebut adalah sebagai berikut : | |
* 1. substring(int beginIndex) | |
* 2. substring(int beginIndex, int endIndex) | |
* Sebagai catatan "int beginIndex" dimulai dari 0 | |
**/ | |
String b = a.substring(2); | |
String c = a.substring(0, 2); | |
System.out.println(b); | |
System.out.println(c); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* program Hitung Nilai | |
* | |
* @author (Cahya, Robi, Iqbal, Budi) | |
* @version (0.1 8/10/2017) | |
*/ | |
import java.io.*; | |
public class no3 | |
{ | |
public static void main(String [] args) | |
{ | |
String a = "iniibubudi"; | |
String b = "123456789"; | |
// variabel C akan menghasilkan nilai 2345 | |
int c= Integer.parseInt(b.substring(1,5)); | |
// variabel D akan menghasilkan nilai 67 | |
int d= Integer.parseInt(b.substring(5,7)); | |
System.out.println(a.substring(1,5)); | |
// variabel C + D sama dengan 2345+67=2412 | |
System.out.println(c+d); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* program Volume Balok | |
* | |
* @author (Cahya, Robi, Iqbal, Budi) | |
* @version (0.1 8/10/2017) | |
*/ | |
import java.io.*; | |
public class no4 | |
{ | |
public static void main(String[] args) | |
{ | |
String s; | |
int p,l,t,volume; | |
try | |
{ | |
FileReader fr = new FileReader("dataku.txt"); | |
BufferedReader br = new BufferedReader(fr); | |
while((s=br.readLine()) != null) | |
{ | |
p = Integer.parseInt(s.substring(2,4)); | |
l = Integer.parseInt(s.substring(3,5)); | |
t = Integer.parseInt(s.substring(8,10)); | |
volume=p*l*t; | |
System.out.printf("Panjang %d Lebar %d "+" Tinggi %d maka volume = %d\n",p,l,t,volume); | |
} | |
br.close(); | |
} | |
catch(IOException e) { | |
System.err.println("File read error"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment