Programming Project 2 - Number Play Note: When you turn in an assignment to be graded in this class, you are making the

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Programming Project 2 - Number Play Note: When you turn in an assignment to be graded in this class, you are making the

Post by answerhappygod »

Programming Project 2 Number Play Note When You Turn In An Assignment To Be Graded In This Class You Are Making The 1
Programming Project 2 Number Play Note When You Turn In An Assignment To Be Graded In This Class You Are Making The 1 (113.72 KiB) Viewed 35 times
Programming Project 2 - Number Play 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 NumberPlay.java that determines if a 6-digit number, when the digits are added together, is modularly divisible by 11. To find this out you will need to randomly generate or enter a 6-digit number. Each digit will then be added together and then modularly divided by 11, to see if its digits are evenly divided by 11. Number Sum Formula: d1 + d2 + d3 + d4 + ds + de = 0 (mod 11) (where di 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 674398, then you would add up: 6+7+4+3+9+8 = 37 % 11 = 4, so not divisible by 11. Example 2, if the number was 103765, then you would add up: 1+0+3+7+ 6 + 5 = 22 % 11 = 0, so divisible by 11. 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 6-digit number and will display the 6-digit number to the user. If the user wants to enter the number, then the program will ask the user for a 6-digit number. The program will output whether the number is divisible by 11 or not divisible by 11. If it is, the program will display the number with a space after it and the text, "is divisible by 11". If it is not, then the computer displays the number with a space after it and the text, "is not divisible by 11". 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 generate a number (1) or enter it yourself (2)? (Note this is one line of output) 2 Enter a 6-digit number 674398 674398 is not divisible by 11 Would you like to randomly generate a number (1) or enter it yourself (2)? (Note this is one line of output) 1 103765 103765 is divisible by 11 Would you like to randomly generate a number (1) or enter it yourself (2)? (Note this is one line of output) 25 Incorrect input Would you like to randomly generate a number (1) or enter it yourself (2)? (Note this is one line of output) 2 Enter a 6-digit number 743 Incorrect input
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply