Results 1 to 9 of 9
  1. #1
    kliane's Avatar
    kliane is offline Member
    Join Date
    Jan 2010
    Posts
    10
    Rep Power
    0

    Smile problem with Scanner in Getting users input

    /*

    Program Name : Fire law regulations
    Description : This program will determine whether a meeting room is in violation of fire law regulation. maximum room capacity is 50.
    */





    import java.awt.*;
    import java.util.Scanner;



    class Fire
    {
    public static void main(String[] args)
    {

    //DECLARATION OF VARIABLES


    int MaxRoomCapacity=50;
    int NumOfPeopleNeeded;
    int NumOfPeopleEx=0;
    int NumOfPeopleAttended;

    Scanner one = new Scanner(System.in);
    System.out.println("How many people will attend?");
    NumOfPeopleAttended = one.nextInt();


    //CALCULATIONS

    if(NumOfPeopleAttended>MaxRoomCapacity)
    {

    NumOfPeopleEx=NumOfPeopleAttended-MaxRoomCapacity;

    System.out.println("The maximum room capacity is " + MaxRoomCapacity);
    System.out.println(NumOfPeopleAttended+" people will be attending.");
    System.out.println("ANNOUNCEMENT: The meeting cannot be held as planned due to fire regulations.");
    System.out.println(NumOfPeopleEx + " people must be excluded in order to meet the maximum room capacity");
    }

    else
    {
    NumOfPeopleNeeded=MaxRoomCapacity-NumOfPeopleAttended;


    System.out.println("The maximum room capacity is " + MaxRoomCapacity);
    System.out.println(NumOfPeopleAttended+" people will be attending.");
    System.out.println("ANNOUNCEMENT: It is legal to hold the meeting.");
    System.out.println(NumOfPeopleNeeded + " more people may legally attend");
    }
    }
    }





    ive got 3 syntax error when i compiled this code it says :

    Microsoft Windows XP [Version 5.1.2600]
    (C) Copyright 1985-2001 Microsoft Corp.

    C:\Documents and Settings\betxx>cd\

    C:\>cd C:\javako

    C:\javako>path=C:\j2sdk1.4.2_05\bin

    C:\javako>javac FireLawReg.java
    FireLawReg.java:13: cannot resolve symbol
    symbol : class Scanner
    location: package util
    import java.util.Scanner;
    ^
    FireLawReg.java:30: cannot resolve symbol
    symbol : class Scanner
    location: class Fire
    Scanner one = new Scanner(System.in);
    ^
    FireLawReg.java:30: cannot resolve symbol
    symbol : class Scanner
    location: class Fire
    Scanner one = new Scanner(System.in);
    ^
    3 errors

    Can anyone help me with this? pls?????

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,001
    Blog Entries
    7
    Rep Power
    20

    Default

    If you had read the latest API documentation for the Scanner class you would've read that a Scanner only saw the light at version 1.5. You seem to have a Java version 1.4.2. installed so you don't have a Scanner. Upgrade to a later version (we are at version 1.6.0.17 or even later now).

    kind regards,

    Jos

  3. #3
    kliane's Avatar
    kliane is offline Member
    Join Date
    Jan 2010
    Posts
    10
    Rep Power
    0

    Default

    hey josAh.. can u help me?

  4. #4
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,001
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by kliane View Post
    hey josAh.. can u help me?
    See above.

    kind regards,

    Jos

  5. #5
    kliane's Avatar
    kliane is offline Member
    Join Date
    Jan 2010
    Posts
    10
    Rep Power
    0

    Default

    can u give me some website wer i cud download that one?

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

    Default

    Quote Originally Posted by kliane View Post
    can u give me some website wer i cud download that one?
    Click the first link here.

    kind regards,

    Jos

  7. #7
    kliane's Avatar
    kliane is offline Member
    Join Date
    Jan 2010
    Posts
    10
    Rep Power
    0

    Default

    tnx for helping me anyway.. i'l try looking for it..

  8. #8
    Syntax's Avatar
    Syntax is offline Member
    Join Date
    Jan 2010
    Location
    Georgia
    Posts
    20
    Rep Power
    0

    Default

    wait Jos, scanner no longer exists? I just started learning last semester and it's already outdated? D:
    11th Grade | Beginner Programmer | Looking into College

  9. #9
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,001
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by Syntax View Post
    wait Jos, scanner no longer exists? I just started learning last semester and it's already outdated? D:
    No, it's the opposite: a Scanner didn't exist before Java 1.5.

    kind regards,

    Jos

Similar Threads

  1. trouble with Scanner(new File("input"));
    By ronyosi in forum New To Java
    Replies: 9
    Last Post: 10-27-2010, 11:34 PM
  2. while loop bypasses scanner input on 2nd pass
    By xf021209 in forum New To Java
    Replies: 2
    Last Post: 02-28-2010, 08:10 AM
  3. Taking args consisting of a scanner input
    By Implode in forum New To Java
    Replies: 1
    Last Post: 09-27-2009, 09:16 PM
  4. Scanner Issues (User Input: Very Simple)
    By carlodelmundo in forum New To Java
    Replies: 8
    Last Post: 10-31-2008, 02:44 AM
  5. Scanner input problem
    By slayer_azure in forum New To Java
    Replies: 3
    Last Post: 05-26-2008, 10:49 PM

Posting Permissions

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