Write a program that takes an integer on the command line

Assignment Help Basic Computer Science
Reference no: EM13870206

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. 

Reference no: EM13870206

Questions Cloud

Basic philosophies of the Phenomenological : it is necessary for you to determine which two personality theories to apply to the character in your chosen film. Choose two of the following theories explored in this course:Psychodynamic,Phenomenological,Behavioral.
What is annual cost of using reliable componets as suppliers : What is the annual cost of using reliable componets as a suppliers and what is annual cost of using Value Electric as a supplier?
outlining the origins of the mental health literacy paradigm : ‘‘mental health literacy''. After outlining the origins of the mental health literacy paradigm, I shall do my best to explain why its application to eating-disordered behavior has merit and how research in this field might be progressed.
Find an article in the news regarding wireless hacking : Research via the internet and find an article in the news regarding wireless hacking, hardware hacking, or other security breach.As security and IT change so rapidly, your article should be no older than 2007 (i.e. Less than 5 years old).Summarize th..
Write a program that takes an integer on the command line : 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
Combines the separately compiled modules of a program : Loader is a system program that combines the separately compiled modules of a program into a form suitable for execution
Culture & ease of doing business : Write a 500 words report on BRAZIL - Culture & Ease of Doing Business
Which of the companies is quicker to convert its receivable : Calculate the receivables turnover ratios and days to collect for Coca-Cola and PepsiCo for 2012 and 2011. (Round to one decimal place) Which of the companies is quicker to convert its receivables into cash?
Detail the embedded system design cycle : Discuss from your personal perspective in detail the embedded system design cycle for a Dell XPS notebook computer and Windows 10 Enterprise operating system.

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Write a program to ask the user to enter the yearly income

Write a program to ask the user to enter the yearly income of each person

  How many total broadcast domains exist on the switch

A switch has been divided using separate VLANs for each of the following departments: Marketing, Engineering, Sales, and Administration. How many total broadcast domains exist on the switch?

  Write the output from instrument class methods

Write the output from your Instrument class methods to a text file that a user entered from the command line arguments (e.g. java Mynamep3tst myfilename.txt). This allows your program to accept filenames from the user via a command line argument.

  Determine the delays of the carry out bit c48

Determine the delays of the carry out bit c48 and the gate complexity, i.e, the numbers of AND, OR and XOR gates needed for implementing the following 48-bit adders.

  What is the length of the string

Consider the string (011) R((01) 2 (01) 0 ) R 1.What is the length of the string over the alphabet {01, 1}?

  The evolution of e-marketing tools

The Evolution of E-Marketing Tools

  Create a program to calculate the average of the class

Define a function "double average(int, int)" to calculate the class average In main function call average function and display the average of the class

  Question based on artificial intelligence

If the brain is a computer and the mind its workings, is this fitting analogy of the computer and its software? What would happen if we had dedicated computers with a huge number of neuron circuits?

  How is targeted advertising done wirelessly

How is targeted advertising done wirelessly

  Write and explain the definition of composition in c++

Write and explain the definition of composition in C++ and how it is useful in writing object-oriented programming. Also, explain how it is different from inheritance and how both inheritance and composition are useful in developing object-oriente..

  Snmp acceptance short paper

SNMP initially appeared in 1988, but it did not receive widespread adoption. What have been the issues with SNMP, and have they been addressed? How widely used is SNMP now? Find some examples of tools that use SNMP.

  What is server side and client side scripting

Describe and explain 5 underlying concepts that drive interaction design. Please include appropriate details and examples with applicable references in APA style.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd