If we input a number formed by 4 digits and these digits are not all of...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
If we input a number formed by 4 digits and these digits are not all of the same value, then it obeys the following law. Let us process the number in the following way: 1. Arrange the digits in the way from bigger to smaller, such that it forms the biggest number that could be made from these 4 digits; 2. Arrange the digits in the way from smaller to bigger, such that it forms the smallest number that could be made from these 4 digits (If there is O among these 4 digits, the number obtained may be less than four digits); 3. Find the difference of these two numbers that is a new four digital number. Repeat the above process (1-3), we get the result 6174 or 0. Write the program to implement the above algorithm. The output from the program should show the procedure for finding this number and the number of repetitions. Sample Input Sample Output 5364 2221 4444 -1 N=5364: 6543-3456-3087 8730-378-8352 8532-2358-6174 Ok!! 3 times N=2221: 2221-1222-999 999-999-0 Ok!! 2 times N=4444: No!! If we input a number formed by 4 digits and these digits are not all of the same value, then it obeys the following law. Let us process the number in the following way: 1. Arrange the digits in the way from bigger to smaller, such that it forms the biggest number that could be made from these 4 digits; 2. Arrange the digits in the way from smaller to bigger, such that it forms the smallest number that could be made from these 4 digits (If there is O among these 4 digits, the number obtained may be less than four digits); 3. Find the difference of these two numbers that is a new four digital number. Repeat the above process (1-3), we get the result 6174 or 0. Write the program to implement the above algorithm. The output from the program should show the procedure for finding this number and the number of repetitions. Sample Input Sample Output 5364 2221 4444 -1 N=5364: 6543-3456-3087 8730-378-8352 8532-2358-6174 Ok!! 3 times N=2221: 2221-1222-999 999-999-0 Ok!! 2 times N=4444: No!!
Expert Answer:
Answer rating: 100% (QA)
Java code import javaioFile import javaioFileNotFoundException import javautilArrayList import javau... View the full answer
Related Book For
International Marketing And Export Management
ISBN: 9781292016924
8th Edition
Authors: Gerald Albaum , Alexander Josiassen , Edwin Duerr
Posted Date:
Students also viewed these programming questions
-
List three specific parts of the Case Guide, Objectives and Strategy Section (See below) that you had the most difficulty understanding. Describe your current understanding of these parts. Provide...
-
The new line character is utilized solely as the last person in each message. On association with the server, a client can possibly (I) question the situation with a client by sending the client's...
-
The quality of information that gives assurance that it is reasonably free of error and bias and is a faithful representation is: a Neutrality b Reliability c Relevance d Verifiability
-
During its first year of operations, Energy Company SE had credit sales of 3,000,000; 600,000 remained uncollected at year-end. The credit manager estimates that 28,000 of these receivables will...
-
Explain why the traditional auditing function cannot serve as the risk management function?
-
What authorizations are required in executing (a) cash receipts and (b) sales adjustments transactions?
-
SkiBlu, Ltd., divides its customers into Gold customers and Silver customers. The company has one full-time customer representative per 1,000 Gold customers and one full-time customer representative...
-
Inventory, by Product Category Quantity Per Unit Cost Net Realizable Value Tools: Hammers Saws Screwdrivers Paint products: 1-gallon cans Paint brushes 110 $ 5.40 $5.90 240 10.40 9.40 340 2.40 3.00...
-
Read the case XYZ Company: An Integrated Capital Budgeting Instructional Case and answer the following question: Should the replacement asset be purchased? That is, does it make economic (financial)...
-
External scale economies are an influence on the pattern of international trade because they affect the number of varieties of a product that are produced in a country. Do you agree or disagree with...
-
If \(1000 \mathrm{~kg} / \mathrm{h}\) of a cottonseed oil-oleic acid solution containing \(25 \mathrm{wt} \%\) acid is to be continuously separated into two products containing 2 and \(90 \mathrm{wt}...
-
The mathematical model of a nonlinear system is provided. Using the procedure outlined in this section, find the operating point and derive the linearized model. \(\begin{cases}\dot{x}_{1}=-x_{1}+3...
-
The mathematical model of a nonlinear system is provided. Using the procedure outlined in this section, find the operating point and derive the linearized model....
-
A nonlinear model is given. a. Obtain the linear state-space form in Simulink. b. Derive the linearized model analytically to confirm the result of (a). \(\ddot{x}+\dot{x}^{3}+x=u(t), \quad u(t)=\)...
-
The mathematical model of a nonlinear system is provided. Using the procedure outlined in this section, find the operating point and derive the linearized model. \(\begin{cases}\dot{x}_{1}=x_{2} &...
-
Evaluate the integral 10 J (x + 1)(x + 9)
-
Why is inventory management important for merchandising and manufacturing firms and what are the main tradeoffs for firms in managing their inventory?
-
Explain when the export firm should no longer be concerned with the pricing of its products.
-
In 1943 a 17-year-old Swedish boy started what was to become a multibillion euro company by selling work pants and other farm supplies door-to-door. Ingvar Kamprad began selling farm implements under...
-
Explain how the Internet may be a valuable source for information, for even the smallest-sized exporter.
-
What are the resources of the organization? How are these used in management decision making?
-
Define management and indicate what its principal purposes are and why managers are essential to organizations.
-
Through the implementation of efficient and effective management, New Belgium Brewing (NBB) has grown from operating out of the founder's basement to having two state-of-the-art facilities and over...
Study smarter with the SolutionInn App