Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You get a job as a magician's assistant. One magic trick that the magician has in their show the Secret Digit. In this trick the

You get a job as a magician's assistant. One magic trick that the magician has in their show the Secret Digit. In this trick the magician brings an audience member onto the stage. He then: 1. Asks then to think of 4 digits (keeping them secret) 2. Asks them to make two numbers with those digits (keeping them secret) 3. Asks them to subtract the smaller number form the larger number (keeping the result secret) 4. Asks them to choose any digit in the difference except 0 (keeping it secret) He then asks the audience member to tell him the remaining three digits and magically tells the audience member the missing digit from step 4 above. What the magician does not tell the audience is that you can talk to him through a hidden earpiece and that you tell him the missing digit. In this assignment you are to write a program that will calculate the missing digit so you can communicate it to the magician. Sample Input/Output Example #1: 1 9 9 The missing digit is: 8 Example #2: 5 7 8 The missing digit is: 7 Example #3: 4 2 1 The missing digit is: 2 I know that this assignment can be a bit confusing: Let's walk through the steps as if we were playing this game in person: 1. I think of a 4-digit number, let's assume I think of 1234 2. I think of two combinations of the digits in that number, let's assume I think of 4132 and 2134 3. I subtract the smaller from the larger (4132 - 2134) that gives me 1998 4. I tell you any three of the digits in that number, let's assume I tell you 1, 9, 9 5. You tell me that the missing digit is 8 HINT: It doesn't matter what two numbers the user is thinking of. What matters is the three ints that they enter. From those three ints you should be able to determine the missing integer. For example: User enters 1, 2, 3 : the missing integer is 3 User enters 1, 1, 1 : the missing integer is 6 User enters 7, 6, 1 : the missing integer is 4 User enters 9, 1, 3 : the missing integer is 5 Do you see a pattern? The missing digit is the number that must be added to the sum of the three digits entered by the user to get a number that is evenly divisible by 9. Name your program: MagicianTrick.Java

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

What do Dimensions represent in OLAP Cubes?

Answered: 1 week ago