There are two problems. In both, as in all programs for this course, you should follow the coding standards for the chapters we have covered so far.
Write and test a program with four static methods for computing the factorial function, n! = 1 × 2 × … × n, for n ≥ 0; for example, 5! = 1 × 2 × 3 × 4 × 5 = 120. The argument and result of the function are non-negative integers. Since the result can be very big, use the Java long type (64-bit integer).
The four methods should use:
for loopwhile loopdo while loopThe main method should ask the user to input n and print four lines showing the results of the four methods calculating n!.
Compile your program and test it. Capture the test I/O in a file. Test cases must include n = 0, n = 10, and two other values of n > 0.
Turn in your source code (i.e., the Java program) and captured test I/O.
Write and test a Java class for book objects. The Book class should have fields for instance data including the book's ISBN-13, author (keep it simple by assuming only one author), title, number of pages, and year of publication. Each of these fields should be suitably encapsulated and "information-hidden": use private declarations, and provide public accessor and mutator methods for each field (also called getter and setter or reader and writer methods). For full credit, the mutator methods for ISBN, number of pages, and year of publication should check for values that are out of reasonable range.
Hints: Don't bother with hyphenating ISBNs; just treat them as numbers.
Modern ISBNs contain decimal 13 digits (ISBN-13); which of the four Java integer data types should you use?
Also define a toString method, which produces a multi-line string that tells us all about the book (i.e., shows us all field values, suitably labeled).
In the main method, create two instances of Book and print them, exercising the toString method. Use the mutator methods to change at least two of the fields, and use the accessor methods and print to confirm the changes. Also show what happens when invalid data are passed to the mutator methods.
Compile and test. Capture your test I/O. Turn in the source code and test I/O.
In Oncourse Assignments, please attach the files in this order: