Created
January 6, 2019 05:10
-
-
Save ilhamarrouf/fc3aa3775aee4e58421b07740394380d to your computer and use it in GitHub Desktop.
Tugas kuliah
This file contains hidden or 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
import java.util.Scanner; | |
import java.util.Calendar; | |
class Movie { | |
public static void main(String args[]) { | |
Scanner reader = new Scanner(System.in); | |
Integer currentYear = Calendar.getInstance().get(Calendar.YEAR); | |
System.out.print("Masukan nama anda : "); | |
String name = reader.nextLine(); | |
System.out.print("Masukan tahun lahir anda : "); | |
Integer birthYear = Integer.parseInt(reader.nextLine()); | |
Integer age = currentYear - birthYear; | |
if (age >= 13 && age < 17) { | |
System.out.println(name + ", anda berusia " + age + " tahun, dapat menonton film dengan klasifikasi SU dan 13+"); | |
} else if (age >= 17 && age < 21) { | |
System.out.println(name + ", anda berusia " + age + " tahun, dapat menonton film dengan klasifikasi SU, 13+ dan 17+"); | |
} else if (age >= 21 && age < 26) { | |
System.out.println(name + ", anda berusia " + age + " tahun, dapat menonton film dengan klasifikasi SU, 13+, 17+ dan 21+"); | |
} else { | |
System.out.println("Adik " + name + ", anda berusia " + age + " tahun, dapat menonton film dengan klasifikasi SU"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment