Concept of a numerical palindrome

Assignment Help Basic Computer Science
Reference no: EM131544432

For this assignment your job is to create two class application that examines the concept of a numerical palindrome.

A numerical palindrome is a non-negative whole number that is the same forwards and backwards, e.g. 2332, 12321, etc. Here's the catch: suppose you do the following. Start with any positive whole number. If it's a palindrome, you're done; if it isn't, reverse the number, add the reversal to the original value, and test this new result. It it's a palindrome, you're done; otherwise repeat: reverse, add, and test again, and so forth. This process almost always leads, very quickly, to a palindrome

A note on how to structure your solution. A NumPal object MUST have four attributes: the current number, its reverse, the String version of the current number, and String version of the reverse of the current number. The numbers should be of type long, not int.

Here's a detailed account of what you need to do for this assignment. You must develop a complete class, NumPal, which works properly with the driver class above, and in that way allows you to turn integer inputs into numerical palindromes. Your submitted code must implement the following methods:

  • Implement the NumPal constructor. Notice that it takes a String argument, NOT an integer argument.
  • Implement the pal() method, which determines if a NumPal object represents a palindrome.
  • Implement the toString() method, which returns a String of the proper form (an example of toString output is given in the first sample run above for 552).
  • Implement the next() method, which - given a NumPal object - returns the next NumPal object according to the "reverse and add" method described above.
  • Implement a reverseString method, which takes a String, say s, as an argument, and returns the reverse of s. Thus reverseString("aabcd") should return the String dcbaa. The code you submit should use this method in an essential way. This method appears as an exercise at the end of Chapter 5 in the textbook.

One final comment. There are clearly many ways to structure a solution to this problem. We've chosen one, and you need to adhere to the pattern we've spelled out above. You may not alter the driver class in any way.

Reference no: EM131544432

Questions Cloud

How has the caste system affected indian society : How has the caste system affected Indian society?Why do Jains often work in banking, education, law, and publishing?
Basic structure of a valid html : Create a static Web page that includes the basic structure of a valid HTML (not XHTML) document.
Are sports to be a masculine activity : You need to elaborate on each question and make sure you answer all four questions. There are no correct or incorrect answers but you must take a clear.
Download free network monitoring tools : Hundreds of network monitoring tools exist. You can purchase or download free network monitoring tools developed by software companies.
Concept of a numerical palindrome : For this assignment your job is to create two class application that examines the concept of a numerical palindrome.
Explain role of technology in development of western society : Discuss the role of religion during this time period. In what ways did religion encourage, discourage, or generally influence social development in Western.
Explain the components of the structure of personality : Explain the components of the structure of personality, which is central to Freudian theory
Employee security-training programs : Discuss what the results are for companies investing in employee security-training programs vs. those who don't.
Two-year european call option on dividend-paying stock : A two-year European call option on a dividend-paying stock is currently selling for $10. what strategy should be taken to exploit arbitrage opportunity,

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Identifies the cost of computer

identifies the cost of computer components to configure a computer system (including all peripheral devices where needed) for use in one of the following four situations:

  Input devices

Compare how the gestures data is generated and represented for interpretation in each of the following input devices. In your comparison, consider the data formats (radio waves, electrical signal, sound, etc.), device drivers, operating systems suppo..

  Cores on computer systems

Assignment : Cores on Computer Systems:  Differentiate between multiprocessor systems and many-core systems in terms of power efficiency, cost benefit analysis, instructions processing efficiency, and packaging form factors.

  Prepare an annual budget in an excel spreadsheet

Prepare working solutions in Excel that will manage the annual budget

  Write a research paper in relation to a software design

Research paper in relation to a Software Design related topic

  Describe the forest, domain, ou, and trust configuration

Describe the forest, domain, OU, and trust configuration for Bluesky. Include a chart or diagram of the current configuration. Currently Bluesky has a single domain and default OU structure.

  Construct a truth table for the boolean expression

Construct a truth table for the Boolean expressions ABC + A'B'C' ABC + AB'C' + A'B'C' A(BC' + B'C)

  Evaluate the cost of materials

Evaluate the cost of materials

  The marie simulator

Depending on how comfortable you are with using the MARIE simulator after reading

  What is the main advantage of using master pages

What is the main advantage of using master pages. Explain the purpose and advantage of using styles.

  Describe the three fundamental models of distributed systems

Explain the two approaches to packet delivery by the network layer in Distributed Systems. Describe the three fundamental models of Distributed Systems

  Distinguish between caching and buffering

Distinguish between caching and buffering The failure model defines the ways in which failure may occur in order to provide an understanding of the effects of failure. Give one type of failure with a brief description of the failure

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