(Beginner Java issues) Why isn't this code working?
<p>(full code below)
I have just handed in a lab for class where we had to make a class that describes a certain book. I could not figure out how to do two things.
1. If someone inputs a value less than zero for the 'pages' or 'suggestedRetailPrice' , the value
must be set to zero. In this code the value is set 0 even if the value is positive. In the:</p>

<hr>

<pre><code>if ( pages &lt;= 0 )
    {
        pages = 0;
    }
</code></pre>

<hr>

<p>code if I set the second '0' to a different number, say:</p>

<hr>

<pre><code>if ( pages &lt;= 0 )
    {
        pages = 1;
    }
</code></pre>

<hr>

<p>Then the value for whatever you input for 'pages' will be 1. But shouldn't it be 1 ONLY if the value you input is a negative number? I don't get what I'm doing wrong.</p>

<p>The second thing I could not figure out is at the bottom of the code, we had to display all info. My teacher wanted us to display whether or not the book was paperback as 'yes' or 'no' instead of 'true' or 'false'. How do I do this? I tried putting an if/else statement in like this:
System.out.println("Paperback : " + if (paperback = true) {Yes} if (paperback = false) {no}; )</p>

<p>Didn't work, can't figure it out. See whole code below.</p>

<hr>

<pre><code>public class Book {
    // Instance variables
    private String title;
    private String author;
    private int isbn;
    private int pages;
    private boolean paperback;
    private int suggestedRetailPrice;

    /**
     * Default contructor
     */
    public Book() {
        title = "";
        author = "";
        isbn = 0;
        pages = 0;
        paperback = false;
        suggestedRetailPrice = 0;
    }

    /**
     * book information
     */
    public Book(String whatIsTitle, String whoIsAuthor, int isbnCode,
            int numberOfPages, boolean isItPaperback,
            int theSuggestedRetailPrice) {
        title = whatIsTitle;
        author = whoIsAuthor;
        isbn = isbnCode;
        if (pages &lt;= 0) {
            pages = 0;
        } else {
            pages = numberOfPages;
        }
        paperback = isItPaperback;
        if (suggestedRetailPrice &lt;= 0) {
            suggestedRetailPrice = 0;
        } else {
            suggestedRetailPrice = theSuggestedRetailPrice;
        }
    }

    /**
     * @return title
     */
    public String getTitle() {
        return title;
    }

    /**
     * @return author
     */
    public String getAuthor() {
        return author;
    }

    /**
     * @return isbn
     */
    public int getIsbn() {
        return isbn;
    }

    /**
     * @return pages
     */
    public int getPages() {
        return pages;
    }

    /**
     * @return paperback
     */
    public boolean getPaperback() {
        return paperback;
    }

    /**
     * @return suggestedRetailPrice
     */
    public int getSuggestedRetailPrice() {
        return suggestedRetailPrice;
    }

    /**
     * title
     */
    public void setTitle(String whatIsTitle) {
        title = whatIsTitle;
    }

    /**
     * author
     */
    public void setAuthor(String whoIsAuthor) {
        author = whoIsAuthor;
    }

    /**
     * isbn code
     */
    public void setIsbn(int isbnCode) {
        isbn = isbnCode;
    }

    /**
     * number of pages
     */
    public void setPages(int numberOfPages) {
        if (pages &lt;= 0) {
            pages = 0;
        } else {
            pages = numberOfPages;
        }
    }

    /**
     * is it paperback
     */
    public void setPaperback(boolean isItPaperback) {
        paperback = isItPaperback;
    }

    /**
     * suggested retail price
     */
    public void setSuggestedRetailPrice(int theSuggestedRetailPrice) {
        if (suggestedRetailPrice &lt;= 0) {
            suggestedRetailPrice = 0;
        } else {
            suggestedRetailPrice = theSuggestedRetailPrice;
        }
    }

    /**
     * displays information
     */
    public void displayBook() {
        System.out.println("Title : " + title);
        System.out.println("Author : " + author);
        System.out.println("ISBN : " + isbn);
        System.out.println("Pages : " + pages);
        System.out.println("Paperback : " + paperback);
        System.out.println("Suggested price : " + suggestedRetailPrice);
    }
}
</code></pre>
