I am about to pull all my hair out!!!!

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("
------------------------------------------");

}

}
}

Comments

  • 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("
    ------------------------------------------");
    :
    : }
    :
    : }
    : }
    :
    :

    [hr]
    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

  • : 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("
    ------------------------------------------");
    :
    : }
    :
    : }
    : }
    :
    :

  • :
    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....
    [code]
    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());

    [/code]

    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("
    ------------------------------------------");
    :
    : }
    :
    : }
    : }
    :
    :

  • :
    Hello again

    Just ran your code through JBuilder

    Heres a few more...
    [code]
    int copeis;
    Should be ....int [blue]copies[/blue];

    for(j=0; J < authorCount; j++)
    should be ...for(j=0; [blue]j[/blue] < authorCount; j++)

    books[i].setBookInfo(title, ISBN, Pubolisher, PublishYear, auth, cost, copies,authorCount);
    should be...books[i].setBookInfo(title, ISBN, [blue]Publisher[/blue], PublishYear, auth, cost, copies,authorCount);
    [/code]
    :
    : 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....
    : [code]
    : 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());
    :
    : [/code]
    :
    : 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
    :
    :
    :
    :
  • 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...
    : [code]
    : int copeis;
    : Should be ....int [blue]copies[/blue];
    :
    : for(j=0; J < authorCount; j++)
    : should be ...for(j=0; [blue]j[/blue] < authorCount; j++)
    :
    : books[i].setBookInfo(title, ISBN, Pubolisher, PublishYear, auth, cost, copies,authorCount);
    : should be...books[i].setBookInfo(title, ISBN, [blue]Publisher[/blue], PublishYear, auth, cost, copies,authorCount);
    : [/code]
    : :
    : : 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....
    : : [code]
    : : 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());
    : :
    : : [/code]
    : :
    : : 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
    : :
    : :
    : :
    : :
    :

  • 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("
    ------------------------------------------");
    : :
    : : }
    : :
    : : }
    : : }
    : :
    : :
    :
    :

  • 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("
    ------------------------------------------");
    : :
    : : }
    : :
    : : }
    : : }
    : :
    : :
    :
    : [hr]
    : 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
    :
    :

  • 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 [b]Book[/b] 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??
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories