class Book

trouble with ISBN digits

Page 1 of 1

2 Replies - 881 Views - Last Post: 15 February 2009 - 12:27 PM Rate Topic: -----

#1 JavaLost  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 15-February 09

class Book

Posted 15 February 2009 - 11:07 AM

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


public class BookCharacteristics2
{
    static Scanner console = new Scanner(System.in);

    public static void main(String[] args) throws 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 FileNotFoundException
    {
    String title;
       String ISBN;
       String Publisher;
       int PublishYear;
       String[] auth = new String[4];
        double cost;
      int copies;
        int authorCount;

       int i, j;

       Scanner infile = new Scanner(new FileReader("bookData.txt"));

     noOfBooks.setNum(infile.nextInt());

  infile.nextLine(); 

  for (i = 0; i < noOfBooks.getNum(); i++)
       {

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

        ISBN[] books = new ISBN[100];

        for (int i = 13; i < 100; i++)
            ISBN[i] = new ISBN();

     IntClass ISBN = new IntClass();

     getISBN(ISBN);
        printISBN(ISBN());
    }

 public static void getBookData(Book[] books, IntClass noOfBooks)
                                throws FileNotFoundException
    {


*edit: Please use code tags in the future, thanks! :code:



I am having trouble figuring out how to code the portion relating to ISBN. I know ISBNs are 13 digits, but am not sure if this code is correct to print out the 13 digit ISBN.

This post has been edited by Martyr2: 15 February 2009 - 11:17 AM


Is This A Good Question/Topic? 0
  • +

Replies To: class Book

#2 Martyr2  Icon User is offline

  • Programming Theoretician
  • member icon

Reputation: 4405
  • View blog
  • Posts: 12,262
  • Joined: 18-April 07

Re: class Book

Posted 15 February 2009 - 11:22 AM

You have some major problems here in this code. You can't have two main methods. On top of that you have one of the main methods defined in the middle of a for loop, which you can never do. Then the last function is not even finished.

Remember that you must have only ONE main method for your project.

Other things that we will need to see is your code for the printISBN() function and keep in mind that you will need to pass it an instance of a book, so instead of passing in ISBN() you will be looking to give it one of the spots from your books array.... printISBN(book[0]); //<-- print ISBN of book 1.

So clean up the code a little bit and show us what is going on and we can then help you further.

Thanks for helping us help you! :)
Was This Post Helpful? 0
  • +
  • -

#3 JavaLost  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 15-February 09

Re: class Book

Posted 15 February 2009 - 12:27 PM

View PostMartyr2, on 15 Feb, 2009 - 10:22 AM, said:

You have some major problems here in this code. You can't have two main methods. On top of that you have one of the main methods defined in the middle of a for loop, which you can never do. Then the last function is not even finished.

Remember that you must have only ONE main method for your project.

Other things that we will need to see is your code for the printISBN() function and keep in mind that you will need to pass it an instance of a book, so instead of passing in ISBN() you will be looking to give it one of the spots from your books array.... printISBN(book[0]); //<-- print ISBN of book 1.

So clean up the code a little bit and show us what is going on and we can then help you further.

Thanks for helping us help you! :)



Why do you state
printISBN(book[0])
I do not understand why you refer to book again. I would think it should refer to ISBN[]

Thanks.




quote name='JavaLost' date='15 Feb, 2009 - 11:25 AM' post='543386']

View PostMartyr2, on 15 Feb, 2009 - 10:22 AM, said:

You have some major problems here in this code. You can't have two main methods. On top of that you have one of the main methods defined in the middle of a for loop, which you can never do. Then the last function is not even finished.

Remember that you must have only ONE main method for your project.

Other things that we will need to see is your code for the printISBN() function and keep in mind that you will need to pass it an instance of a book, so instead of passing in ISBN() you will be looking to give it one of the spots from your books array.... printISBN(book[0]); //<-- print ISBN of book 1.

So clean up the code a little bit and show us what is going on and we can then help you further.

Thanks for helping us help you! :)

[/quote]
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1