473,383 Members | 1,997 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

reached end of file while parsing

13
Hi,can somebody help me, I am trying to compile a programm but have an error
it is called reached end of file while parsing?? Anyone mind th have a look for some help

public class records
{
public static void main (String args[]){
System.out.println("Enter name");
float name = Keyboard.readInt();

switch (name) {
case Ryan:
System.out.println ("I.D. 0569290(M) SURNAME Mifsud GROUP NO 1");
break;

switch (name) {
case Robert:
System.out.println ("I.D. 086790(M) SURNAME Vella GROUP NO 3");
break;

switch (name) {
case Victor:
System.out.println ("I.D. 0548790(M) SURNAME Cassar GROUP NO 5");
break;

switch (name) {
case Jim:
System.out.println ("I.D. 0971790(M) SURNAME Dimech GROUP NO 8");
break;

switch (name) {
case Sam:
System.out.println ("I.D. 0321790(M) SURNAME Muscat GROUP NO 10");
break;

switch (name) {
case Leo:
System.out.println ("I.D. 0104790(M) SURNAME MIfsud GROUP NO 2");
break;

switch (name) {
case Glen:
System.out.println ("I.D. 0274790(M) SURNAME Borg GROUP NO 6");
break;

switch (name) {
case Kyle:
System.out.println ("I.D. 0721790(M) SURNAME Fabri GROUP NO 11");
break;

switch (name) {
case Kurt:
System.out.println ("I.D. 0589790(M) SURNAME Caruana GROUP NO 2");
break;

switch (name) {
case Ian:
System.out.println ("I.D. 0761790(M) SURNAME Grima GROUP NO 4");
break;

default:
System.out.println("Invalid name");
}
} the error is on the last bold bracket
Jul 17 '07 #1
13 5865
JosAH
11,448 Expert 8TB
There's a whole lot wrong with your program. The syntax of a switch statement
is like this:

Expand|Select|Wrap|Line Numbers
  1. switch (<integer expression>) {
  2.    case <integer constant expression>: <statements>
  3.    ...
  4.    case <integer constant expression>: <statements>
  5.    default: <statements> // but 'default is optional
  6. }
  7.  
But the worst error is: you can't switch on a float type (a name?). You have
to redesign the whole lot. And where do these Jims, Kens, Marys come from?

kind regards,

Jos
Jul 17 '07 #2
blazedaces
284 100+
Hi,can somebody help me, I am trying to compile a programm but have an error
it is called reached end of file while parsing?? Anyone mind th have a look for some help

Expand|Select|Wrap|Line Numbers
  1. public class records
  2. {
  3.     public static void main (String args[]){
  4.         System.out.println("Enter name");
  5.             float  name = Keyboard.readInt();
  6.  
  7.         switch (name) {
  8.             case Ryan:
  9.                 System.out.println ("I.D. 0569290(M)  SURNAME Mifsud GROUP NO 1");
  10.                 break;
  11.  
  12.         switch (name) {
  13.             case Robert:
  14.                 System.out.println ("I.D. 086790(M)  SURNAME Vella GROUP NO 3");
  15.                 break;
  16.  
  17.             switch (name) {
  18.                 case Victor:
  19.                     System.out.println ("I.D. 0548790(M)  SURNAME Cassar GROUP NO 5");
  20.                     break;
  21.  
  22.             switch (name) {
  23.                 case Jim:
  24.                     System.out.println ("I.D. 0971790(M)  SURNAME Dimech GROUP NO 8");
  25.                     break;
  26.  
  27.             switch (name) {
  28.                 case Sam:
  29.                     System.out.println ("I.D. 0321790(M)  SURNAME Muscat GROUP NO 10");
  30.                     break;
  31.  
  32.             switch (name) {
  33.                 case Leo:
  34.                     System.out.println ("I.D. 0104790(M)  SURNAME MIfsud GROUP NO 2");
  35.                     break;
  36.  
  37.             switch (name) {
  38.                 case Glen:
  39.                     System.out.println ("I.D. 0274790(M)  SURNAME Borg GROUP NO 6");
  40.                     break;
  41.  
  42.             switch (name) {
  43.                 case Kyle:
  44.                     System.out.println ("I.D. 0721790(M)  SURNAME Fabri GROUP NO 11");
  45.                     break;
  46.  
  47.             switch (name) {
  48.                 case Kurt:
  49.                     System.out.println ("I.D. 0589790(M)  SURNAME Caruana GROUP NO 2");
  50.                     break;
  51.  
  52.             switch (name) {
  53.                 case Ian:
  54.                     System.out.println ("I.D. 0761790(M)  SURNAME Grima GROUP NO 4");
  55.                     break;
  56.  
  57.             default:
  58.                 System.out.println("Invalid name");
  59.         }
  60.     }
the error is on the last bold bracket
Hello, and welcome to TSDN. First of all, from now on if you could please try and put your code in code tags (look on the right when you're posting to the box that says "REPLY GUIDELINES").

Now, I don't know if this is the exact problem, but I know it is one that needs fixing, this line:

Expand|Select|Wrap|Line Numbers
  1. float  name = Keyboard.readInt();
  2.  
That should be readFloat() right ...? Also, when are you instantiating your scanner keyboard... I don't see it. Is this really the only error you're receiving?

OH OH, I found your problem. I'm almost 100% sure it says this when you have not closed your brackets properly. Add another bracket on the bottom there ok... try that. If not, count your brackets again, there should be an exact number of pairs, one close bracket for each open...

Hope that helped,

-blazed
Jul 17 '07 #3
max3
13
hi i'am an absolute beginner in programming. I am trying to create a database program for my school project which I urgenty need. the program is a database which when i input names it gives me information (Surname, I.D. no Group ) about the person.Could you please guide me through the writing of this program.thanks
Jul 17 '07 #4
JosAH
11,448 Expert 8TB
hi i'am an absolute beginner in programming. I am trying to create a database program for my school project which I urgenty need. the program is a database which when i input names it gives me information (Surname, I.D. no Group ) about the person.Could you please guide me through the writing of this program.thanks
Try a Properties object first. You can have a little text file that looks like this:
Expand|Select|Wrap|Line Numbers
  1. Ryan= I.D. 0569290(M) SURNAME Mifsud GROUP NO 1
  2. Robert= I.D. 086790(M) SURNAME Vella GROUP NO 3
  3. Victor= I.D. 0548790(M) SURNAME Cassar GROUP NO 5
  4. Jim= I.D. 0971790(M) SURNAME Dimech GROUP NO 8
  5. Sam= I.D. 0321790(M) SURNAME Muscat GROUP NO 10
  6.  
etc. etc. A Properties object can read itself given an InputStream. First check
out the "article index" post in the Java Articles section. At the end of that
article you can find a link where you can download the complete API documentation
for all the Java core classes. Please download the stuff and read all about the
Properties class.

kind regards,

Jos
Jul 17 '07 #5
blazedaces
284 100+
hi i'am an absolute beginner in programming. I am trying to create a database program for my school project which I urgenty need. the program is a database which when i input names it gives me information (Surname, I.D. no Group ) about the person.Could you please guide me through the writing of this program.thanks
Hold up there man. Take this one step at a time. Split this into as many tiny parts you have to understand and come up with. What do you know/have done before and what do you not have a clue about? Do you need to make it as complex as you're making it? The old saying comes to mind: "keep it simple stupid". Just keep it simple, step by step, we can get through this.

-So you're going to input names, first get that down pat. Write a program that asks the user for a name, then prints it to the screen.

-Next, go to sun's tutorial website and take some tutorials on using databases (not an easy step, but you need it if you want to tackle databases)

-Then write a program that simply spits out info from the database.

-Then write a program that asks a user for something and prints the info.

It should be even more steps, but you get the picture...

Good luck,

-blazed
Jul 17 '07 #6
max3
13
this programm needs to have ten persons ?? am I using a good method ??
Jul 17 '07 #7
blazedaces
284 100+
this programm needs to have ten persons ??
Why are you asking us?
am I using a good method ??
Method to do what? Design a program that involves a database and information retrieval? Which method are you talking about?

-blazed
Jul 17 '07 #8
max3
13
What does orphaned default means??
Jul 17 '07 #9
JosAH
11,448 Expert 8TB
What does orphaned default means??
Don't think about that for now, you can't use a switch statement for your purposes.

kind regards,

Jos
Jul 17 '07 #10
max3
13
which statement in your opinion should i use??if you are saying switch is not good ??
Jul 17 '07 #11
JosAH
11,448 Expert 8TB
which statement in your opinion should i use??if you are saying switch is not good ??
Don't think about that either; as blazedaces suggested: try to read a name from
somewhere and echo it back on the screen. Try to accomplish that first. Better
take a lot of baby steps you *do* understand instead of one big step that baffles
you. You have to learn how to walk before you can run; really.

kind regards,

Jos
Jul 17 '07 #12
blazedaces
284 100+
which statement in your opinion should i use??if you are saying switch is not good ??
You technically could use a switch statement, but a switch is always of either an integer, or a character. It can not be of a string or a float.

You technically could make an array of strings, then when you ask the user for a name (Which I'm assuming you want the name to be a string, so you should be doing "String" name = keyboard.read() or something like that...) you could search for it in your array and then use a switch of the index (location in the array) where that string is stored. Then spit out the data.

I'm going to have to say though, this is unnecessarily complex. It doesn't need to be. Re-evaluate.

What EXACTLY do you need to do? It's a school project right? What are the specific requirements (you don't need to tell me, just think about it again). Maybe you don't need a database. Maybe you don't need a switch statement. Think about what you need and think of another solution...

Good luck
-blazed
Jul 17 '07 #13
jkmyoung
2,057 Expert 2GB
1. You want a string name not an integer.
Use String name = Keyboard.readLine();
or readString()
depending on what Keyboard class you are using.

2. You cannot switch on a string. Unfortunately you'd have to use if/else statements. eg.
if (name.equals("Jonathan")) {
// some action
} else if (name.equals("Jimmy")){
// some other action ..
} ...


3. For string comparison you have to use .equals() as opposed to == operator.
Jul 17 '07 #14

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Hari Om | last post by:
Here are the details of my error log files: I execute the command and get following message at console: ---------------------------------------------------------------------- ../sqlldr...
2
by: Oxmard | last post by:
Armed with my new O'Reilly book Optimizing Oracle Performance I have been trying to get a better understanding of how Oracle works. The book makes the statement, " A database cal with dep=n + 1...
2
by: Cigdem | last post by:
Hello, I am trying to parse the XML files that the user selects(XML files are on anoher OS400 system called "wkdis3"). But i am permenantly getting that error: Directory0: \\wkdis3\ROOT\home...
7
by: christian.eickhoff | last post by:
Hi Everyone, I am currently implementing an XercesDOMParser to parse an XML file and to validate this file against its XSD Schema file which are both located on my local HD drive. For this...
5
by: baskarpr | last post by:
Hi all, I my program after parsing in SAX parser, I want to write the parse result as an XML file. I want to ensure that there should be no difference between source XML file and parse result xml...
5
AdrianH
by: AdrianH | last post by:
Assumptions I am assuming that you know or are capable of looking up the functions I am to describe here and have some remedial understanding of C++ programming. FYI Although I have called...
1
AdrianH
by: AdrianH | last post by:
Assumptions I am assuming that you know or are capable of looking up the functions I am to describe here and have some remedial understanding of C programming. FYI Although I have called this...
7
by: souravmallik | last post by:
Hello, I'm facing a big logical problem while writing a parser in VC++ using C. I have to parse a file in a chunk of bytes in a round robin fashion. Means, when I select a file, the parser...
3
by: spittinfire | last post by:
-------------------------------------------------------------------------------- I am trying to correct the errors on an assignment that has already been graded because I have to now modify it and...
1
by: kk975kom | last post by:
Hi can somebody help me ,iam trying to compile my java program but display error was reached end of file while parsing .please find the error in program.
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.