18+

  • 2
  • Locked
Would any child close a website after being informed that it is not intended for anybody under 18? Despite being entirely ineffective, this age "verification" process is still used. Let's write a program that asks the user's age. If the answer is <18, the program displays "Grow up a little more".
You can't complete this task, because you're not signed in.
Comments (5)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
ZhaXi
Level 8 , 杭州, China
19 December 2022, 01:02
BufferedReader bis = new BufferedReader(new InputStreamReader(System.in)); String name = bis.readLine(); // why need this? int age = Integer.parseInt(bis.readLine());//why not this : int age = Integer.parseInt(reader.readLine()); if (age < 18) { System.out.println("Grow up a little more");
Joe M
Level 47 , Owings Mills, United States
28 September 2020, 12:39
OK got it after 22 attempts on one of the easiest tasks...I think after a couple of tries you should be sure to hit "reset"..then enter fresh code....still happy I am learning about templates and Buffered Reader
Lex Medeiros
Level 18 , San Jose, Costa Rica
20 March 2019, 23:42
Could someone tell me what I am doing wrong? Below is the code and here is the error I get:
package com.codegym.task.task04.task0422;

/*
18+

*/

import java.io.*;

public class Solution {
    public static void main(String[] args) throws Exception {
        //write your code here
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        System.out.println("Please enter your Name");
        String name = reader.readLine();
        System.out.println("Please enter your age");
        String ageInputed = reader.readLine();
        int age = Integer.parseInt(ageInputed);


        if(age < 18) {
            System.out.println("Grow up a little more");
        }
    }
}
Roman
Level 41
21 March 2019, 07:23
If you need help, something isn't right in your code, the server won't accept your solution (even if you are 100% sure that it is correct). Describe your question/issue in the HELP section at codegym.cc/help.
Syed Huzaifa
Level 7 , Karachi, Pakistan
4 May 2020, 11:30
Bro! Try not to print any other lines ("please enter your name" or "please enter your age") because the last 2 conditions are clearing that u don't have to print anything else (except "Grow up a little more", if the condition of age less then 18 is match)