Results 1 to 6 of 6

Thread: help

  1. #1
    fyah is offline Member
    Join Date
    Sep 2013
    Posts
    2
    Rep Power
    0

    Exclamation help

    Im just strating programming and I cant find what Im doing wrong can somebody rewrite it for me properly so I have an example of how to do it please?? in the easiest way as possible!


    public static void main(String[] args) {
    System.out.println("Enter a positive number:");
    Scanner scan = new Scanner(system.in);
    int num1 = scan.nextInt();{
    if(num1 <=6);
    System.out.print("Sorry you have failed");
    if(num1 >=7)
    System.out.print("Congratulations you have passed");
    }

    thanks

  2. #2
    JBelg is offline Member
    Join Date
    Oct 2012
    Posts
    36
    Rep Power
    0

    Default Re: help

    What's the problem, what doesn't work?

  3. #3
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,380
    Blog Entries
    7
    Rep Power
    20

    Default Re: help

    Quote Originally Posted by fyah View Post
    Im just strating programming and I cant find what Im doing wrong can somebody rewrite it for me properly so I have an example of how to do it please?? in the easiest way as possible!


    public static void main(String[] args) {
    System.out.println("Enter a positive number:");
    Scanner scan = new Scanner(system.in);
    int num1 = scan.nextInt();{
    What is that trailing left curly bracket doing there?

    Quote Originally Posted by fyah View Post
    if(num1 <=6);
    What is that trailing semicolon doing there?

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  4. #4
    fyah is offline Member
    Join Date
    Sep 2013
    Posts
    2
    Rep Power
    0

    Default Re: help

    Quote Originally Posted by JosAH View Post
    What is that trailing left curly bracket doing there?



    What is that trailing semicolon doing there?

    kind regards,

    Jos

    Hi jos thank you so much for replying the only line that is giving me an error is this one

    Scanner scan = new Scanner(system.in);

    and I cant understand why but then again im just getting bak in to programming now after 4 years
    cant remember this things anymore. I few so stupid hope you can help. thank you

  5. #5
    Ubiquitous is offline Member
    Join Date
    Sep 2013
    Posts
    10
    Rep Power
    0

    Default Re: help

    Take a look at the parameter you are giving new Scanner(). What do you access to print out something? It is a case sensitive issue so for example String is not the same as string.

  6. #6
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,380
    Blog Entries
    7
    Rep Power
    20

    Default Re: help

    Quote Originally Posted by fyah View Post
    Hi jos thank you so much for replying the only line that is giving me an error is this one

    Scanner scan = new Scanner(system.in);

    and I cant understand why but then again im just getting bak in to programming now after 4 years
    cant remember this things anymore. I few so stupid hope you can help. thank you
    The name is 'System', not 'system'. You should always pay attention to the case of those names in Java.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •