Java

Moderators: zibadian
Number of threads: 7836
Number of posts: 18235

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
I am about to pull all my hair out!!!! Posted by Moeski on 30 Nov 2004 at 8:59 AM
Good Morning..I'm in the process of trying to run one of my progams that's due for class and I'm getting and error which I'm sure it's a typo on my behave, but I was wondering if someone could take a look at it:

import java.io.*;
import java.util.*;

public class program8
{
static BufferedReader keyboard = new
BufferedReader(new InputStreamReader(system.in));

public static void main(String[] args) throws IOException,
FileNotFoundException
{

Book[] books = new Book [100];

for (int i= 0; i< 100; i++)
books [i] = new Book ();

IntClass numberOfBooks = new IntClass();

getBookData(books, numberOfBooks);
printBookData (books, numberOfBooks.getNum ());
}
public static void getBookData(Book[] books, IntClass noOfBooks) throws IOException, FileNotFoundException
{

String title;
String ISBN;
String Publisher;
int PublishYear;
String [] auth = new String [4];
double cost;
int copeis;
int authorCount;

int i, j;
BufferedReader infile = new
BufferedRearder (new FileReader ("a:\\bookData.txt"));

StringTokenizer tokenizer;

noOfBooks.setNum(Integer.parsenInt(infile.readLine()));

for ( i= 0; i < noOfBooks.getNum(); i++)
{
title = infile.readLine ();
ISBN = infile.readLine ();
Publisher = infile.readLine();
PublishYear = Integer.parseInt(infile.readLine());
cost = Double.parseDouble(infile.readLine());
copies = Integer.parseInt (infile.readLine());
authorCount = Integer.pareseInt(infile.readLine());

for(j=0; J < authorCount; j++)
auth[j] = infile.readLine();

books[i].setBookInfo(title, ISBN, Pubolisher, PublishYear, auth, cost, copies,authorCount);
}
}
public static void printBookData (Book [] books, int noOfBooks)
{
int i;

for (i = 0; i < noOfBooks; i++)
{
books [i].printInfo();
System.out.println("\n ------------------------------------------");

}

}
}

Report
Re: I am about to pull all my hair out!!!! Posted by velius on 30 Nov 2004 at 3:23 PM
you have system.in and it should be System.in. that's the first thing I noticed and did not go further. ^^
: Good Morning..I'm in the process of trying to run one of my progams that's due for class and I'm getting and error which I'm sure it's a typo on my behave, but I was wondering if someone could take a look at it:
:
: import java.io.*;
: import java.util.*;
:
: public class program8
: {
: static BufferedReader keyboard = new
: BufferedReader(new InputStreamReader(system.in));
:
: public static void main(String[] args) throws IOException,
: FileNotFoundException
: {
:
: Book[] books = new Book [100];
:
: for (int i= 0; i< 100; i++)
: books [i] = new Book ();
:
: IntClass numberOfBooks = new IntClass();
:
: getBookData(books, numberOfBooks);
: printBookData (books, numberOfBooks.getNum ());
: }
: public static void getBookData(Book[] books, IntClass noOfBooks) throws IOException, FileNotFoundException
: {
:
: String title;
: String ISBN;
: String Publisher;
: int PublishYear;
: String [] auth = new String [4];
: double cost;
: int copeis;
: int authorCount;
:
: int i, j;
: BufferedReader infile = new
: BufferedRearder (new FileReader ("a:\\bookData.txt"));
:
: StringTokenizer tokenizer;
:
: noOfBooks.setNum(Integer.parsenInt(infile.readLine()));
:
: for ( i= 0; i < noOfBooks.getNum(); i++)
: {
: title = infile.readLine ();
: ISBN = infile.readLine ();
: Publisher = infile.readLine();
: PublishYear = Integer.parseInt(infile.readLine());
: cost = Double.parseDouble(infile.readLine());
: copies = Integer.parseInt (infile.readLine());
: authorCount = Integer.pareseInt(infile.readLine());
:
: for(j=0; J < authorCount; j++)
: auth[j] = infile.readLine();
:
: books[i].setBookInfo(title, ISBN, Pubolisher, PublishYear, auth, cost, copies,authorCount);
: }
: }
: public static void printBookData (Book [] books, int noOfBooks)
: {
: int i;
:
: for (i = 0; i < noOfBooks; i++)
: {
: books [i].printInfo();
: System.out.println("\n ------------------------------------------");
:
: }
:
: }
: }
:
:



We'll be an army of theives
Of self-freed slaves
Of mild-mannered maids
We'll fight with whispers and blades
So get ready, a new day is dawning
- The New Wild West -- Jewel

Report
Re: I am about to pull all my hair out!!!! Posted by Moeski on 5 Dec 2004 at 5:08 PM
Yes. I caught that and I've made the changes.

Thanks


: you have system.in and it should be System.in. that's the first thing I noticed and did not go further. ^^
: : Good Morning..I'm in the process of trying to run one of my progams that's due for class and I'm getting and error which I'm sure it's a typo on my behave, but I was wondering if someone could take a look at it:
: :
: : import java.io.*;
: : import java.util.*;
: :
: : public class program8
: : {
: : static BufferedReader keyboard = new
: : BufferedReader(new InputStreamReader(system.in));
: :
: : public static void main(String[] args) throws IOException,
: : FileNotFoundException
: : {
: :
: : Book[] books = new Book [100];
: :
: : for (int i= 0; i< 100; i++)
: : books [i] = new Book ();
: :
: : IntClass numberOfBooks = new IntClass();
: :
: : getBookData(books, numberOfBooks);
: : printBookData (books, numberOfBooks.getNum ());
: : }
: : public static void getBookData(Book[] books, IntClass noOfBooks) throws IOException, FileNotFoundException
: : {
: :
: : String title;
: : String ISBN;
: : String Publisher;
: : int PublishYear;
: : String [] auth = new String [4];
: : double cost;
: : int copeis;
: : int authorCount;
: :
: : int i, j;
: : BufferedReader infile = new
: : BufferedRearder (new FileReader ("a:\\bookData.txt"));
: :
: : StringTokenizer tokenizer;
: :
: : noOfBooks.setNum(Integer.parsenInt(infile.readLine()));
: :
: : for ( i= 0; i < noOfBooks.getNum(); i++)
: : {
: : title = infile.readLine ();
: : ISBN = infile.readLine ();
: : Publisher = infile.readLine();
: : PublishYear = Integer.parseInt(infile.readLine());
: : cost = Double.parseDouble(infile.readLine());
: : copies = Integer.parseInt (infile.readLine());
: : authorCount = Integer.pareseInt(infile.readLine());
: :
: : for(j=0; J < authorCount; j++)
: : auth[j] = infile.readLine();
: :
: : books[i].setBookInfo(title, ISBN, Pubolisher, PublishYear, auth, cost, copies,authorCount);
: : }
: : }
: : public static void printBookData (Book [] books, int noOfBooks)
: : {
: : int i;
: :
: : for (i = 0; i < noOfBooks; i++)
: : {
: : books [i].printInfo();
: : System.out.println("\n ------------------------------------------");
: :
: : }
: :
: : }
: : }
: :
: :
:
:

: We'll be an army of theives
: Of self-freed slaves
: Of mild-mannered maids
: We'll fight with whispers and blades
: So get ready, a new day is dawning
: - The New Wild West -- Jewel
:
:

Report
Re: I am about to pull all my hair out!!!! Posted by colklnk on 4 Dec 2004 at 8:30 PM
: I had to do the same program for school-Malik/Nair Let me know if you get the program to run. I know when I did it I had to save my program on the a drive in order for it to work. There are other students in the class that no matter what they did the jsdk would not process the program and the program was correct. What school do you go to?

Good Morning..I'm in the process of trying to run one of my progams that's due for class and I'm getting and error which I'm sure it's a typo on my behave, but I was wondering if someone could take a look at it:
:
: import java.io.*;
: import java.util.*;
:
: public class program8
: {
: static BufferedReader keyboard = new
: BufferedReader(new InputStreamReader(system.in));
:
: public static void main(String[] args) throws IOException,
: FileNotFoundException
: {
:
: Book[] books = new Book [100];
:
: for (int i= 0; i< 100; i++)
: books [i] = new Book ();
:
: IntClass numberOfBooks = new IntClass();
:
: getBookData(books, numberOfBooks);
: printBookData (books, numberOfBooks.getNum ());
: }
: public static void getBookData(Book[] books, IntClass noOfBooks) throws IOException, FileNotFoundException
: {
:
: String title;
: String ISBN;
: String Publisher;
: int PublishYear;
: String [] auth = new String [4];
: double cost;
: int copeis;
: int authorCount;
:
: int i, j;
: BufferedReader infile = new
: BufferedRearder (new FileReader ("a:\\bookData.txt"));
:
: StringTokenizer tokenizer;
:
: noOfBooks.setNum(Integer.parsenInt(infile.readLine()));
:
: for ( i= 0; i < noOfBooks.getNum(); i++)
: {
: title = infile.readLine ();
: ISBN = infile.readLine ();
: Publisher = infile.readLine();
: PublishYear = Integer.parseInt(infile.readLine());
: cost = Double.parseDouble(infile.readLine());
: copies = Integer.parseInt (infile.readLine());
: authorCount = Integer.pareseInt(infile.readLine());
:
: for(j=0; J < authorCount; j++)
: auth[j] = infile.readLine();
:
: books[i].setBookInfo(title, ISBN, Pubolisher, PublishYear, auth, cost, copies,authorCount);
: }
: }
: public static void printBookData (Book [] books, int noOfBooks)
: {
: int i;
:
: for (i = 0; i < noOfBooks; i++)
: {
: books [i].printInfo();
: System.out.println("\n ------------------------------------------");
:
: }
:
: }
: }
:
:

Report
Re: I am about to pull all my hair out!!!! Posted by Moeski on 5 Dec 2004 at 5:06 PM
I finally got it to run after reviewing it over and over... I'll print down what you have and compare it to mind when I return back to work on Monday... I know one of my problems was that I did not have my class file created, then there was another bookdata file that I created but did not change the drive to read from A.

I'm currently a junior at Davenport University and really have second thoughts about program........

I have another program that's due so I'm working on that now.. I'll send you what I currently have it I have problems with that running.

Thanks for your time!




: : I had to do the same program for school-Malik/Nair Let me know if you get the program to run. I know when I did it I had to save my program on the a drive in order for it to work. There are other students in the class that no matter what they did the jsdk would not process the program and the program was correct. What school do you go to?
:
: Good Morning..I'm in the process of trying to run one of my progams that's due for class and I'm getting and error which I'm sure it's a typo on my behave, but I was wondering if someone could take a look at it:
: :
: : import java.io.*;
: : import java.util.*;
: :
: : public class program8
: : {
: : static BufferedReader keyboard = new
: : BufferedReader(new InputStreamReader(system.in));
: :
: : public static void main(String[] args) throws IOException,
: : FileNotFoundException
: : {
: :
: : Book[] books = new Book [100];
: :
: : for (int i= 0; i< 100; i++)
: : books [i] = new Book ();
: :
: : IntClass numberOfBooks = new IntClass();
: :
: : getBookData(books, numberOfBooks);
: : printBookData (books, numberOfBooks.getNum ());
: : }
: : public static void getBookData(Book[] books, IntClass noOfBooks) throws IOException, FileNotFoundException
: : {
: :
: : String title;
: : String ISBN;
: : String Publisher;
: : int PublishYear;
: : String [] auth = new String [4];
: : double cost;
: : int copeis;
: : int authorCount;
: :
: : int i, j;
: : BufferedReader infile = new
: : BufferedRearder (new FileReader ("a:\\bookData.txt"));
: :
: : StringTokenizer tokenizer;
: :
: : noOfBooks.setNum(Integer.parsenInt(infile.readLine()));
: :
: : for ( i= 0; i < noOfBooks.getNum(); i++)
: : {
: : title = infile.readLine ();
: : ISBN = infile.readLine ();
: : Publisher = infile.readLine();
: : PublishYear = Integer.parseInt(infile.readLine());
: : cost = Double.parseDouble(infile.readLine());
: : copies = Integer.parseInt (infile.readLine());
: : authorCount = Integer.pareseInt(infile.readLine());
: :
: : for(j=0; J < authorCount; j++)
: : auth[j] = infile.readLine();
: :
: : books[i].setBookInfo(title, ISBN, Pubolisher, PublishYear, auth, cost, copies,authorCount);
: : }
: : }
: : public static void printBookData (Book [] books, int noOfBooks)
: : {
: : int i;
: :
: : for (i = 0; i < noOfBooks; i++)
: : {
: : books [i].printInfo();
: : System.out.println("\n ------------------------------------------");
: :
: : }
: :
: : }
: : }
: :
: :
:
:

Report
Re: I am about to pull all my hair out!!!! Posted by beancounter on 4 Dec 2004 at 9:23 PM
:
Hello

Since I don't have all your other class files I can't run your code to completion. However I did note a few typos....
BufferedReader(new InputStreamReader(system.in)); 
Should be... BufferedReader(new InputStreamReader(System.in)); 

BufferedRearder (new FileReader ("a:\\bookData.txt")); 
Should be...BufferedReader (new FileReader ("a:\\bookData.txt")); 

noOfBooks.setNum(Integer.parsenInt(infile.readLine())); 
Should be...noOfBooks.setNum(Integer.parseInt(infile.readLine())); 

authorCount = Integer.pareseInt(infile.readLine()); 
Should be....authorCount = Integer.parseInt(infile.readLine()); 



Since I can't test your code I don't know if these changes will fix your problem.

Good luck let us know if this works.

Ken



Good Morning..I'm in the process of trying to run one of my progams that's due for class and I'm getting and error which I'm sure it's a typo on my behave, but I was wondering if someone could take a look at it:
:
: import java.io.*;
: import java.util.*;
:
: public class program8
: {
: static BufferedReader keyboard = new
: BufferedReader(new InputStreamReader(system.in));
:
: public static void main(String[] args) throws IOException,
: FileNotFoundException
: {
:
: Book[] books = new Book [100];
:
: for (int i= 0; i< 100; i++)
: books [i] = new Book ();
:
: IntClass numberOfBooks = new IntClass();
:
: getBookData(books, numberOfBooks);
: printBookData (books, numberOfBooks.getNum ());
: }
: public static void getBookData(Book[] books, IntClass noOfBooks) throws IOException, FileNotFoundException
: {
:
: String title;
: String ISBN;
: String Publisher;
: int PublishYear;
: String [] auth = new String [4];
: double cost;
: int copeis;
: int authorCount;
:
: int i, j;
: BufferedReader infile = new
: BufferedRearder (new FileReader ("a:\\bookData.txt"));
:
: StringTokenizer tokenizer;
:
: noOfBooks.setNum(Integer.parsenInt(infile.readLine()));
:
: for ( i= 0; i < noOfBooks.getNum(); i++)
: {
: title = infile.readLine ();
: ISBN = infile.readLine ();
: Publisher = infile.readLine();
: PublishYear = Integer.parseInt(infile.readLine());
: cost = Double.parseDouble(infile.readLine());
: copies = Integer.parseInt (infile.readLine());
: authorCount = Integer.pareseInt(infile.readLine());
:
: for(j=0; J < authorCount; j++)
: auth[j] = infile.readLine();
:
: books[i].setBookInfo(title, ISBN, Pubolisher, PublishYear, auth, cost, copies,authorCount);
: }
: }
: public static void printBookData (Book [] books, int noOfBooks)
: {
: int i;
:
: for (i = 0; i < noOfBooks; i++)
: {
: books [i].printInfo();
: System.out.println("\n ------------------------------------------");
:
: }
:
: }
: }
:
:

Report
Re: I am about to pull all my hair out!!!! Posted by beancounter on 4 Dec 2004 at 10:16 PM
:
Hello again

Just ran your code through JBuilder

Heres a few more...
int copeis;
Should be ....int copies;

for(j=0; J < authorCount; j++)
should be ...for(j=0; j < authorCount; j++)

books[i].setBookInfo(title, ISBN, Pubolisher, PublishYear, auth, cost, copies,authorCount);
should be...books[i].setBookInfo(title, ISBN, Publisher, PublishYear, auth, cost, copies,authorCount);

:
: Hello
:
: Since I don't have all your other class files I can't run your code to completion. However I did note a few typos....
:
: BufferedReader(new InputStreamReader(system.in)); 
: Should be... BufferedReader(new InputStreamReader(System.in)); 
: 
: BufferedRearder (new FileReader ("a:\\bookData.txt")); 
: Should be...BufferedReader (new FileReader ("a:\\bookData.txt")); 
: 
: noOfBooks.setNum(Integer.parsenInt(infile.readLine())); 
: Should be...noOfBooks.setNum(Integer.parseInt(infile.readLine())); 
: 
: authorCount = Integer.pareseInt(infile.readLine()); 
: Should be....authorCount = Integer.parseInt(infile.readLine()); 
: 
: 

:
: Since I can't test your code I don't know if these changes will fix your problem.
:
: Good luck let us know if this works.
:
: Ken
:
:
:
:
Report
Re: I am about to pull all my hair out!!!! Posted by Moeski on 5 Dec 2004 at 5:02 PM
Thanks for you help... I some some of my typo's after reviewing it several times. I was able to get it to run..Sorry about not providing you with the class tables, but it looks like I'm all set... Thanks again!!! Now I'm working on my last programmer so hopefully things will go good, if not I'll be in touch...

Thanks AGain!

: Hello again
:
: Just ran your code through JBuilder
:
: Heres a few more...
:
: int copeis;
: Should be ....int copies;
: 
: for(j=0; J < authorCount; j++)
: should be ...for(j=0; j < authorCount; j++)
: 
: books[i].setBookInfo(title, ISBN, Pubolisher, PublishYear, auth, cost, copies,authorCount);
: should be...books[i].setBookInfo(title, ISBN, Publisher, PublishYear, auth, cost, copies,authorCount);
: 

: :
: : Hello
: :
: : Since I don't have all your other class files I can't run your code to completion. However I did note a few typos....
: :
: : BufferedReader(new InputStreamReader(system.in)); 
: : Should be... BufferedReader(new InputStreamReader(System.in)); 
: : 
: : BufferedRearder (new FileReader ("a:\\bookData.txt")); 
: : Should be...BufferedReader (new FileReader ("a:\\bookData.txt")); 
: : 
: : noOfBooks.setNum(Integer.parsenInt(infile.readLine())); 
: : Should be...noOfBooks.setNum(Integer.parseInt(infile.readLine())); 
: : 
: : authorCount = Integer.pareseInt(infile.readLine()); 
: : Should be....authorCount = Integer.parseInt(infile.readLine()); 
: : 
: : 

: :
: : Since I can't test your code I don't know if these changes will fix your problem.
: :
: : Good luck let us know if this works.
: :
: : Ken
: :
: :
: :
: :
:

Report
Re: I am about to pull all my hair out!!!! Posted by shebon on 17 Feb 2009 at 10:40 AM
Folks, I am trying to do a similar problem and its confusing like hell. Can someone please help, if you have the solution already?

my first question
Book[] books = new Book [100]
where is the class Book that is being instantiated here and what is it supposed to do? Can someone please provide the code for that?
second question
IntClass numberOfBooks = new IntClass();
where is the code for class IntClass and what is it supposed to do?
third question
I fail to understand the purpose of the line items listed below. Where did they come from, I dont see them initialized in the program. Are they are part of the class Book?
getBookData(books, numberOfBooks);
printBookData (books, numberOfBooks.getNum ());

Can someone please help??



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.