Results 1 to 9 of 9
- 01-17-2010, 12:53 PM #1
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?????
- 01-17-2010, 01:07 PM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,606
- Blog Entries
- 7
- Rep Power
- 17
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
- 01-17-2010, 01:07 PM #3
hey josAh.. can u help me?
- 01-17-2010, 01:08 PM #4
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,606
- Blog Entries
- 7
- Rep Power
- 17
- 01-17-2010, 01:08 PM #5
can u give me some website wer i cud download that one?
- 01-17-2010, 01:10 PM #6
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,606
- Blog Entries
- 7
- Rep Power
- 17
Click the first link here.
kind regards,
Jos
- 01-17-2010, 01:11 PM #7
tnx for helping me anyway.. i'l try looking for it..
- 01-17-2010, 04:22 PM #8
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
- 01-17-2010, 04:37 PM #9
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,606
- Blog Entries
- 7
- Rep Power
- 17
Similar Threads
-
trouble with Scanner(new File("input"));
By ronyosi in forum New To JavaReplies: 9Last Post: 10-27-2010, 11:34 PM -
while loop bypasses scanner input on 2nd pass
By xf021209 in forum New To JavaReplies: 2Last Post: 02-28-2010, 08:10 AM -
Taking args consisting of a scanner input
By Implode in forum New To JavaReplies: 1Last Post: 09-27-2009, 09:16 PM -
Scanner Issues (User Input: Very Simple)
By carlodelmundo in forum New To JavaReplies: 8Last Post: 10-31-2008, 02:44 AM -
Scanner input problem
By slayer_azure in forum New To JavaReplies: 3Last Post: 05-26-2008, 10:49 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks