Created
September 27, 2016 10:48
-
-
Save fahmidwi/156b231dcf991220048ebff7f3484d59 to your computer and use it in GitHub Desktop.
PBO - problem solving kedua,
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
package com.belajar.aritmatika; | |
//class Profile | |
public class Profile{ | |
public String nama; | |
public String kelas; | |
public int lahir; | |
int hitungUmurKu(int thnSekarang, int thnLahir){ | |
return thnSekarang-thnLahir; | |
}; | |
} | |
/* | |
pada line ke 7 : ganti type data variabel menjadi int | |
pada line ke 9 : hilangakan public void ganti menjadi int dan String pada thnLahir ganti menjadi int | |
*/ |
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
package com.belajar.aritmatika; | |
public class Siswa{ | |
public static void main ( String[] args ){ | |
Profile myProfile = new Profile(); | |
myProfile.nama = "rizki"; | |
myProfile.kelas = "RPL 1"; | |
myProfile.lahir = 2000; | |
System.out.println("namaku : "+myProfile.nama); | |
System.out.println("kelas :" +myProfile.kelas); | |
System.out.println("umurku sekarang :"+myProfile.hitungUmurKu(2016, +myProfile.lahir)); | |
} | |
} | |
/* | |
pada line ke 5 : tambahkan syntax void dan | |
pada line ke 5 : syntax string ubah menjadi String | |
pada line ke 7 : profile ganti menjadi Profile | |
pada line ke 8 : myProfil.nama ganti menjadi myProfile.nama | |
pada line ke 9 : ganti myProfile,kelas menjadi myProfile.kelas dan tambahkan kutip pada isi variabel "RPL 1" | |
pada line ke 10: variabel hanya menggunakan 1 sama dengan dan tidak menggunakan kutip dua (myProfile.lahir = 2000 ) | |
pada line ke 12: +myProfile.name ganti menjadi +myProfile.nama | |
pada line ke 13: System.Out.println ganti menjadi System.out.println | |
pada line ke 13: kutip pindah ke belakang : ("kelas :") | |
pada line ke 13: +myprofile.kelas ganti menjadi myProfile.kelas | |
pada line ke 14: "2016" hilangkan kutip dua menjadi 2016 | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment