Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

Write a program called Assg4.java to solve the following problem.

Write a program to solve the following problem. Given a small integer (e.g. 78), we can reverse it (giving 87) and add the reverse to itself (giving 165). If this is performed repeatedly then usually a number that is a palindrome is eventually produced.

Write a program that takes an integer on the command line, checks that it is not negative or bigger than 200 (in which case a suitable message should be printed and no computation performed) and then prints it out followed by every number that is produced during repeatedly performing the above operation until a palindromic number is produced. A typical run should be as follows.

% java Assg4 78
78
165
726
1353
4884
The number 78 took 4 steps to reach a palindrome.

In addition, your program should terminate with an error message if more than 10 steps are taken, as follows.

% java Assg4 89
89
187
968
1837
9218
17347
91718
173437
907808
1716517
8872688
The number 89 takes more than 10 steps to reach a palindrome.

[Note that you may safely ignore the possibility of integer overflow in this assignment, given the size and iteration limits imposed above.]

Hint: One way to proceed is to write static methods to convert an int to a String and vice-versa first, and test them. Then write a static method to test whether or not a String is a palindrome, and test it. Now use these methods to help solve the problem. 

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M91535328

Have any Question?


Related Questions in Computer Engineering

Why are standards needed in data communication and

Why are standards needed in data communication and networking? What are the advantages and disadvantages of standards? How do standards fit in with regulations at the federal, manufacturing, and organizational levels? Gi ...

Assignmentthe smurfware smurfscanner is a new biometric

Assignment The SmurfWare SmurfScanner is a new biometric authentication device to keep non-Smurfs out of the Smurfland network. The biometric device is being dubbed the SmurfScanner by Papa Smurf. The SmurfScanner is a h ...

What are the key nonprice factors that influence demand and

What are the key nonprice factors that influence demand and supply?

How many electrons in a tellurium te atom have a principal

How many electrons in a tellurium (Te) atom have a principal quantum number of n = 4 and a magnetic quantum number of m l  = 0? a)2 b) 3 c) 6 d) 9 e) 18 Why does Beryllium (Be) have a positive electron affinity? ( That i ...

Problemtelephone calls arrive at the rate of 12 per hour at

Problem Telephone calls arrive at the rate of 12 per hour at the reservation desk for Regional Airways. a. Find the probability of receiving 3 calls in a 4-minute interval. If required, round your answer to four decimal ...

In 2015 caterpillar inc had about 757 million shares

In 2015, Caterpillar Inc. had about 757 million shares outstanding. Their book value was $41.0 per share, and the market price was $93.50 per share. The company's balance sheet shows that the company had $34.50 billion o ...

Question unless otherwise stated answer in complete

Question: Unless otherwise stated, answer in complete sentences, and be sure to use correct English spelling and grammar. Sources must be cited in APA format. Your response should be four (4) pages in length; refer to th ...

Kelly and jennifer are roommates kelly loves listening to

Kelly and Jennifer are roommates. Kelly loves listening to rock music and uses the radio in their common area to play it. Jennifer, on the other hand, prefers the peace and quiet around the common area. Answer the follow ...

Question you company provides wireless networking services

Question: You company provides wireless networking services. One of your customers complains about the downloading performance being poor. After investigation, you find that the customer's 802.11 wireless network is inte ...

Letang industrial systems company lisc is trying to decide

Letang Industrial Systems Company (LISC) is trying to decide between two different conveyor belt systems. System A costs $300,000, has a four-year life, and requires $101,000 in pretax annual operating costs. System B co ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As