Skip to content

Instantly share code, notes, and snippets.

@ilhamarrouf
Created January 6, 2019 05:10
Show Gist options
  • Save ilhamarrouf/fc3aa3775aee4e58421b07740394380d to your computer and use it in GitHub Desktop.
Save ilhamarrouf/fc3aa3775aee4e58421b07740394380d to your computer and use it in GitHub Desktop.
Tugas kuliah
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