Question
Page of 5 ZOOM Programming Project 2 Number Sum Note: When you turn in an assignment to be graded in this class, you are making
Page
of 5
ZOOM
Programming Project 2 Number Sum Note: When you turn in an assignment to be graded in this class, you are making the claim that you neither gave nor received assistance on the work you turned in (except, of course, assistance from the instructor or teaching assistants).Write a program called NumberSum.java that determines if a number, when properly configured, is modularly divisible by 11, 9, or 6 based on the users input. To find this out you will need to randomly generate or enter a 5-digit number. You can randomly generate each digit independently or the number all at once. Each digit will then be placed into the following formula and to determine if it is modularly divisible by 11, 9, or 6. Number Sum Formula: 5d1 + 4d2 + 3d3 + 2d4 + 1d5 0 (mod 11 or mod 9 or mod 6) (where d1 is the first digit of the number, starting on the left-hand side, d2 is the next digit, and so on.)Example 1, if the number was 67439, then you would add up: 5*6 + 4*7 + 3*4 + 2*3 + 1*9 = 85 % 11 = 8, so not divisible by 11. 5*6 + 4*7 + 3*4 + 2*3 + 1*9 = 85 % 9 = 4, so not divisible by 9. 5*6 + 4*7 + 3*4 + 2*3 + 1*9 = 85 % 6 = 1, so not divisible by 6. Example 2, if the number was 03063, then you would add up: 5*0 + 4*3 + 3*0 + 2*6 + 1*3 = 27 % 11 = 5, so not divisible by 11. 5*0 + 4*3 + 3*0 + 2*6 + 1*3 = 27 % 9 = 0, so is divisible by 9. 5*0 + 4*3 + 3*0 + 2*6 + 1*3 = 27 % 6 = 3, so not divisible by 6. The program will first ask the user if they would like to randomly generate a number or enter it. If the user picks the randomly generated number, the program will use Math.random() to randomly generate the digits and will display the 5-digit number to the user. If the user wants to enter the number, then the program will ask the user for a 5-digit number. The program will then ask the user if they would like to see if the number is divisible by 11, 9 or 6. Once the user has entered their choice, the program will output whether the number is divisible by the number the user chose, 11, 9 or 6 or not divisible by that
number. If it is, the program will display the number with a space after it and the text, is divisible by 11/9/6. If it is not, then the computer displays the number with a space after it and the text, is not divisible by 11/9/6.The program will also be able to handle incorrect integer input. If the user does not enter a number that is expected the program will state, Incorrect input. Here are some sample runs:Would you like to randomly enter a number (1) or enter it yourself (2)? 2Enter a 5-digit number.67439Would you like to see if this number is divisible by 11, 9 or 6? Enter the number you would like to divide this number by. 667439 is not divisible by 6.Would you like to randomly enter a number (1) or enter it yourself (2)? 133063Would you like to see if this number is divisible by 11, 9 or 6? Enter the number you would like to divide this number by. 933063 is not divisible by 9.
Would you like to randomly enter a number (1) or enter it yourself (2)? 154386Would you like to see if this number is divisible by 11, 9 or 6? Enter the number you would like to divide this number by. 654386 is divisible by 6.Would you like to randomly enter a number (1) or enter it yourself (2)? 25Incorrect inputWould you like to randomly enter a number (1) or enter it yourself (2)? 2Enter a 5-digit number.743Incorrect inputWould you like to randomly enter a number (1) or enter it yourself (2).?2Enter a 5-digit number.67439Would you like to see if this number is divisible by 11, 9 or 6? Enter the number you would like to divide this number by. 10Incorrect input
This and all program files in this course must include a comment block at the beginning (top) of the source code file that contains: the Java program name project description your name the version date the course number and sectionThe comment lines should look like this:/* * Java program name * * Project description * Your name * The version date * The course number and section */Before beginning this project, you will document your algorithm as a list of steps to take you from your inputs to your outputs. This will be graded mostly for completion and returned to you. It will be your responsibility to understand and correct any errors you might have with your algorithm. Each step of your algorithm will be added as a comment block within your code. You will have the comment block right above the code that performs the actions specified. For example, before your lines of code that ask the user for inputs, you would have a comment block that states what inputs you are requesting from the user.You will test your program when you run it at the command line / terminal. You need to have a test case for each path through your program. I have given you some samples of tests to run in the examples above.You will submit the following: Java source code file (NumberSum.java) to Gradescope A screenshot showing the running of at least four test cases at the command line / terminal that will test all the major paths through the program to the assignment link in Canvas.
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