5
jdmkaan
8y

@reesmid

Here is a working implementation.

Comments
  • 1
    @h3ll exactly what I was thinking about lol
  • 2
    @Lukas no, its needed to tell the user of he is too young or not every time he input an age
  • 2
    @altermind Haha..hit the bar too late :) I'll delete my stupid remark and ++ you sir;)
  • 1
    @jdmkaan thank you. i see some changes in WHILE... great. I was practicing in an application on my phone. may be don't run correctly because that.
  • 1
    int x;
    do{
    x = scanner.nextInt();
    if(x<16)
    System.out.println("too young");
    } while (x<16)

    System.out.println("welcome");
  • 1
    @burungbangkai and here we observe a far easier way to go about problem solving
  • 0
    @tisaconundrum nope. The program does not even take into account if the user messes up and enters something other than an integer. It needs to be able to rerun autonomously without ending and running again on user's end.
  • 0
    Isn't there a place for code help? It's called overstack, stackflow... What is that place...

    Right! stackoverflow... Ah yes. Good old Stack Overflow. 😾
  • 0
    @jdmkaan reasons for type checking
  • 0
    @jdmkaan while I understand what you're getting at. Well written code is also important and reducing redundancies saves you a lot of time and heartache for you and future developers who have to work with your code.
  • 0
    @ingenioushax stack overflow is fine. But it's a Terrible place for noobies, if they don't know how to ask questions that won't get down voted to death
  • 1
    int x = 0;
    int minAge = 16;
    Scanner scanner = new Scanner(system.in);
    do
    {
    try
    {
    x = scanner.nextInt();
    x < minAge ? system.out.println("Too young") : system.out.println("welcome");
    }
    catch(MismatchTypeException ex)
    {
    system.out.println("Enter a number you buffoon");
    }
    }while(x < minAge);
  • 1
    that if statement for age != 16 and age < 16 is making me cringe
  • 0
    @ingenioushax upvote for buffoon
  • 0
    And that snippet ladies and gents, is the second time I have ever written Java. 🤗
Add Comment