CMSC 201 |
Homework 6 - Due 10/30This homework must be submitted by 5pm on the due date to get any credit. In this homework, we'll be working on integrating smaller parts of a program into a larger whole. Please pay attention to the formatting, as we will require your output be in the same format as ours. You will be writing a program that analyzes numbers for the user. You will print a menu, asking them if they want to find the greatest common divisor of two numbers, whether a number is perfect, the goldbach decomposition of a number, or all the prime factors of a number. The user should also have an option to quit. You are required to have the following functions (but you are welcome to use more):
If the user enters a number that is not amoung the menu options, or a number that is not appropriate for a given test, they should be reprompted to enter one until a number in the correct range is entered. Sample output is below: Please enter a choice: 1. Greatest common divisor 2. Perfect number check 3. Goldbach decomposition 4. Prime Factors 5. Quit 1 Please enter a positive integer: 60 Please enter a positive integer: 40 The greatest common divisor of 60 and 40 is 20 Please enter a choice: 1. Greatest common divisor 2. Perfect number check 3. Goldbach decomposition 4. Prime Factors 5. Quit 2 Please enter a positive integer: -3 Number not acceptable. Please enter a positive integer: 10 10 is not a perfect number. Please enter a choice: 1. Greatest common divisor 2. Perfect number check 3. Goldbach decomposition 4. Prime Factors 5. Quit 2 Please enter a positive integer: 6 6 is a perfect number. Please enter a choice: 1. Greatest common divisor 2. Perfect number check 3. Goldbach decomposition 4. Prime Factors 5. Quit 8 Number not acceptable Please enter a choice: 1. Greatest common divisor 2. Perfect number check 3. Goldbach decomposition 4. Prime Factors 5. Quit 3 Please enter a positive even integer greater than 4: 2 Number not acceptable. Please enter a positive even integer greater than 4: 8 The goldbach decomposition of 8 is 3 and 5. Please enter a choice: 1. Greatest common divisor 2. Perfect number check 3. Goldbach decomposition 4. Prime Factors 5. Quit 4 Please enter a positive integer: 15 The prime factors of 15 are [1, 3, 5] Please enter a choice: 1. Greatest common divisor 2. Perfect number check 3. Goldbach decomposition 4. Prime Factors 5. Quit 5 Quitting... SubmittingWhen you've finished your homework, use the submit command to submit the file. You must be logged into your account and you must be in the same directory as the file you're trying to submit. At the Linux prompt, type submit cs201 HW6 hw6.pyAfter entering the submit command shown above, you should get a confirmation that submit worked correctly: Submitting hw6.py...OKIf not, check your spelling and that you have included each of the required parts and try again. You can check your submission by entering: submitls cs201 HW6You should see the name of the file that you just submitted, in this case hw6.py |
Adapted from UMBC CSHC's webpage design |