Post: Staring Java Again
03-14-2013, 01:13 AM #1
zertzHD
Bounty hunter
(adsbygoogle = window.adsbygoogle || []).push({}); Starting to learn Java..again. I quit the first time, but this time I'm sticking at it for good. Here's a little script I just made. Was testing out how variables, if statements, and scanners work.

    import java.util.Scanner;


public class agecheck {



public static void main(String[] args) {


Scanner jonny = new Scanner(System.in);
int age;
System.out.println("Please Enter Your Age");
age = jonny.nextInt();
if (age > 17) {
System.out.println("You are admitted!");

}else{
System.out.println("Sorry, you are too young.");

}
}

}
(adsbygoogle = window.adsbygoogle || []).push({});
03-15-2013, 06:31 PM #2
Pichu
RIP PICHU.
Just letting you know, you don't need to put code blocks if it's a single line after an if-else statement:

    
if (age >17)
System.out.println("You are admitted!");
else
System.out.println("Sorry, you are too young.");


Little pointer. Smile
03-18-2013, 04:36 AM #3
Izl
Do a barrel roll!
looks good keep it up. what if someone typed Eighteen? or 18.0 ?

Copyright © 2026, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo