Homework #9

- To practice using loops and conditional statements
- To practice using graphical user interfaces

For this project you are asked to design and implement a simple application that allows the user to enter two positive integers and reports their greatest common factor (GCF). The greatest common factor is the largest number that evenly divides both numbers.

The application should contain a label prompting the user to enter the two numbers, text fields where they enter their input, and a button to click to calculate the GCF. When the button is clicked, the answer should be displayed as a label next to the button.

After entering two numbers, and clicking the button, the application should look like the following sample:

Your design should include a method called `gcf`

that takes two positive
integers as parameters and returns their greatest common factor.

Draw a UML class diagram to design your application, showing all of the fields and methods, including their accessibility (public or private) and data types.

Your `gcf`

method should use a simple "brute force" approach
to finding the GCF. Starting with the smaller of the two integers, try
successively smaller numbers until you find a common factor. Write and test
this method before designing your user interface.

- In the
`gcf`

method, use a loop!

When your assignment is complete, add some comments to the comment block of the java source code explaining any problems you encountered in completing the assignment and describing any bugs in your solution.

Submit your source code as well as your class diagram as email attachments to your lab instructor.
Alternatively, you may submit your class diagram in hardcopy.
Use the subject line **CIS-180 HW#9** in your email.

**Make sure you send your homework to the proper place.
Homework sent to the wrong address may not receive credit!**

Lab Section | Grader | ||
---|---|---|---|

L1 | Mon. 2PM | Wes Fowlks | u_wfowlks@umassd.edu |

L2 | Wed. 9AM | Neelima Mothe | nmothe@umassd.edu |

L3 | Wed. 1PM | Wes Fowlks | u_wfowlks@umassd.edu |

There will be a 10% penalty for assignments received after the due date. Assignments will not be accepted more than one week past the due date.