Algorithm Sample - Are you legally an adult?

package algorithmsample1;

import java.util.Scanner;

/**
 *
 * @author Nurhak
 */
public class AlgorithmSample1 {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int age = 0;

        System.out.println("Please enter your age!");
        try {
            age = scan.nextInt();
            if (age >= 18) {
                System.out.println("You are legally an adult!");
            } else {
                System.out.println("You are not legally an adult!");
            }
        } catch (Exception e) {
            System.out.println("Please enter a valid value!");
        }
    }
}

Comments

Popular posts from this blog

Solution for the fault: "System.Diagnostics.Process.Start is not working on IIS, but working on ASP.NET Development Server"

Solution for "Can not obtain Oracle client information from registry"