123456789101112131415161718192021222324252627282930313233343536373839 |
- import java.util.Scanner;
-
- class Beslutninger {
- private static void a() {
- int age = 18;
- }
-
- private static void b() {
- int age = 18;
-
- //Checks the user's age, telling whether they're legal age or not
- if (age >= 18) {
- System.out.println("You're of legal age.");
- } else {
- System.out.println("You're not of legal age.");
- }
- }
-
- private static void c() {
- Scanner s = new Scanner(System.in);
-
- //Asks the user how old they are
- System.out.println("How old are you?");
- int age = s.nextInt();
-
- //Checks the user's age, telling whether they're legal age or not
- if (age >= 18) {
- System.out.println("You're of legal age.");
- } else {
- System.out.println("You're not of legal age.");
- }
- }
-
- public static void main(String[] args) {
- a();
- b();
- c();
- }
- }
|