Hello everyone,
I'm new to java and I'm working on a assignment, but I couldn't compile the BookTest.java.

Here's my Book.java

    package question_1;

    public class Book {

    private String title;      // Title of the book 
    private String author;     // Author of book :
    private String isbn;       // International Standard Book Number 0-13-213198-7
    private float cost;        // Cost of the book in U.S. dollars

    public Book() {
        title = "UnKnown";
        author = "UnKnown";
        isbn = "UnKnown";
        cost = 0;
    }

    public Book(String _title, String _author, String _isbn, float _cost) {
        title = _title;
        author = _author;
        isbn = _isbn;
        cost = _cost;
    }

    public String getTitle() {
        return title;
    }

    public String getAuthor() {
        return author;
    }

    public String getIsbn() {
        return isbn;
    }

    public float getCost() {
        return cost;
    }

    public void setTitle(String _title) {
        title = _title;
    }

    public void setAuthor(String _author) {
        author = _author;
    }

    public void setIsbn(String _isbn) {
        isbn = _isbn;
    }

    public void setCost(float _cost) {
        cost = _cost;
    }

    public double convertUsToEuro() {
        double euroconverted = 0;
        euroconverted = .73 * cost;
        return euroconverted;
    }
}

And here's my BookTest.java:

package question_1;

import javax.swing.JFrame;
import javax.swing.JOptionPane;
import java.*;
public class BookTest {

    public void test() {
        System.out.println("Begin test");
        Book book1 = new Book("Programing Java", "Sun System", "001", 86);
        Book book2 = new Book("Programing C#", "MS", "002", 89);
        /// print output for user
        JOptionPane.showMessageDialog(new JFrame(), "Book 1nTitle: " + book1.getTitle() + "nAuthor: " + book1.getAuthor() + "nISBN: " + book1.getIsbn() + "nCost in USD: " + book1.getCost() + "nCost in Euro: " + book1.convertUsToEuro());
        JOptionPane.showMessageDialog(new JFrame(), "Book 2nTitle: " + book2.getTitle() + "nAuthor: " + book2.getAuthor() + "nISBN: " + book2.getIsbn() + "nCost in USD: " + book2.getCost() + "nCost in Euro: " + book2.convertUsToEuro());
    }

    public static void main(String[] args) {
        BookTest obj = new BookTest();
        obj.test();
    }
}

Errors:

BookTest.java:14: cannot find symbol
symbol  : class Book
location: class question_1.BookTest
        Book book1 = new Book("Programing Java", "Sun System", "001", 86);
        ^
BookTest.java:14: cannot find symbol
symbol  : class Book
location: class question_1.BookTest
        Book book1 = new Book("Programing Java", "Sun System", "001", 86);
                         ^
BookTest.java:15: cannot find symbol
symbol  : class Book
location: class question_1.BookTest
        Book book2 = new Book("Programing C#", "MS", "002", 89);
        ^
BookTest.java:15: cannot find symbol
symbol  : class Book
location: class question_1.BookTest
        Book book2 = new Book("Programing C#", "MS", "002", 89);
                         ^
4 errors

Thank you very much for any help.

I couldn't compile the BookTest.java.

Please post the full text of the error messages.

Whoops, just saw the error messages.

Check the definition for the Book class's constructor and make sure you have the correct number and types of parameters being passed to it.

The code compiles with no errors for me.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.