Question
Java Why is the chapters giving me a zero constantly private String subject; private int numPages; private int chapters; private static final int Pages_per_chapter =
Java Why is the chapters giving me a zero constantly
private String subject; private int numPages; private int chapters; private static final int Pages_per_chapter = 20;
public Textbook( String subject, int numPages) { this.subject = subject; this.numPages = numPages; } public String getSubject() { return subject; }
public void setSubject(String subject) { this.subject = subject; }
public int getNumPages() { return numPages; }
public void setNumPages(int numPages) { this.numPages = numPages; }
public static int getNumPagesPerChapter() { return Pages_per_chapter; }
public int getChapters() { return chapters; } public static int numChapters(int numPages){ int chapters=0; chapters+=(numPages/Pages_per_chapter); numPages=numPages%20; if(numPages>19) chapters++; return chapters; }
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started