CIS73666.doc Lab Assignment 6 Due 10-26-09
Object Oriented Java Programming I
This week
we are going to write an application program file that will present the user
with a main menu that allows the user to select from three options:
The first
option will execute a private method for calculating the factorial of a number
and then return control to the main menu. The second option will execute a
private method for displaying a table of powers and return control to the main
menu. The third option will terminate the application. The coding in the main
method should continue to re-execute in a loop until the user selects option 3.
The main method should display a menu followed by a switch statement that calls
a private method to perform either option 1 or option 2. The specs for options
1 and 2 are as follows:
Option 1 – Method 1
1. The method prompts the user to enter a valid
integer from 1 to 9. Assume
a valid integer is entered. Verifiy that the value
entered is from 1 to 9.
2. The method displays the factorial of the
number entered by the user. Use a for loop to
calculate the factorial and store the factorial in a long integer.
3. The method prompts the user to continue to
re-execute the method or return to the main menu. The method will continue only
if the user enters “y”
or “Y” to continue
.
1. The method prompts the user to enter
an integer from 1 to 7. Assume a valid integer is entered. Verifiy
that the value entered is from 1 to 7. The method displays a table that has the
number, the square of the number, the cube of the number, and the square root
of the number on one line, for all of the numbers from 1 to the value entered
by the user.
2. The
method then prompts the user to continue to re-execute the method or return to
the main menu. The method will continue only if the user enters “y” or “Y” to
continue.
Option 3
1. This
option should terminate the application by forcing the while loop in the main
to exit the loop to the end of the main.
You might consider putting the code to display the menu and execute the
switch statement inside of a do while loop, and only continue executing the do
while loop if the user has previously selected option 1 or option 2. See “Menu
with a Switch” on the Sample List which can be referenced from the class web
site.
Notes: (See new notes 8 – 14)
1. Label the end of all classes, methods, and blocks with a
comment.
2. Line up the beginning brace { and
ending brace } vertically for each block. (i.e. for
each class, method, and block)
3. Indent all code between the beginning and ending braces
so that the lineup of braces can be easily observed.
4. Include comments at the
beginning of every .java source file
with the assignment number, author, date due, and an essay (with paragraphs) at
the start of the file describing the functionality of each class as well as how
each class “works”. User instructions should also be provided. Are there comments
reference important or complex syntax?
5. Insert dividers/separators (i.e. a line of dashes or a line of asterisks) between each method and class.
6. Capture your test results and paste them into the end of
your .java source class file as comments.
7. Submit an electronic copy of your .java source class
files for credit. Note that all submissions should be made as attachments to an
email, and sent to the instructor with the following subject line:
CIS73
Lab x
where x = the lab assignment number. Note that the subject line is case sensitive. All assignments should be submitted on or before the due date for full credit per the course policies.
8. All data output should have data titles.
9. All primitive data should be formatted on output.
10. Prompts should be used for all data input from the keyboard.
11. All code should be tested and included in the test results output.
12. All objects declared and used in the main( ) should be passed to other private static methods (example …a Scanner object) in lieu of recreating them in the private static methods.
13. No static methods (including the main) should be more than one screen full long.
14. Note once again that all duplicate .java files that are
submitted for a grade will NOT be graded.
15. If you
are having problems that you and your classmates cannot resolve, you should
review the “Suggestions for Success” on my home page and attempt to resolve
them in our 2 hours of lab sessions each week. Note that there are 3 class
tutors that are available in the lab for a total of 10 hours each week plus
they are available by appointment. If all else fails then get back to me via
email or make an appointment with me.....We care about the students that care!
“There is no substitution for adequate preparation.”