Examines the concept of a numerical palindrome

Assignment Help Basic Computer Science
Reference no: EM131548694

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: EM131548694

Questions Cloud

Thomas-kilmann conflict mode instrument : Choose Thomas-Kilmann Conflict Mode Instrument (TKI) .The TKI is used to assess a person's behavior in conflict situations.
Would you rather use conditional or joint probability : When working with research, would you rather use conditional or joint probability? Explain.
Define revitalizing of business plans to assess new products : During this course, the writing and expansion of thought incited by Kuratko (2013) has re-energized concepts and principles I have a long subscribe.
What goals would you set for the sales staff : What behaviors would you advise ACI to look for in hiring ACI's sales staff? What goals would you set for the sales staff?
Examines the 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 the major geographical exposure : Include the nature of its products or services. Explain the major geographical exposure. Explain the major source of foreign exposure.
Discuss the kotter eight-step plan : As part of your reflection exercise for Week 8, reflect on a major change that you had experienced personally or at your workplace.
Discuss the greatest challenges to sound decision-making : Explain the incentives in this scenario. Were they effective? Discuss the greatest challenges to sound decision-making in your scenario.
Investing in employee security-training programs : Discuss what the results are for companies investing in employee security-training programs vs. those who don't.

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Derive the best response function below

For each firm, derive the best response function below. Show all work. You may not use the concept of symmetry to obtain your answer.

  Car average between the two fillings

A motorist wants to determine her gas mileage. At 23,352 miles (on the odometer), the tank is filled. At 23,695 miles the tank is filled again with 14 gallons. How many miles per gallon did the car average between the two fillings?

  Who is princeton.edu and who is princeton for starters

The Unix utility who is can be used to find the domain name corresponding to an organization, or vice versa. Read the man page documentation for who is and experiment with it. Try who is princeton.edu and who is princeton, for starters.

  Determine the value of a that will yield a system

If n = 16 and x = 4 MIPS, determine the value of α that will yield a system performance of 40 MIPS.

  Finding the shortest distance between oblique lines

Finding the Shortest Distance between Oblique Lines. With the use of a grid, reference lines, and auxiliary views, find the shortest distance between the oblique lines for the two problems shown in Fig. 7-69. Scale to suit.

  Write a function that convert any angles outside of interval

Suppose that an array contains angles in degrees. Write a function that converts any angles outside of the interval [0,360] to an equivalent angle in that interval. For example, an angle of 380.5 degrees should be converted to 20.5 degrees.

  Write some java statements that test the class

Consider a Java class that you could use to get an acceptable integer value from the user. An object of this class will have the attributes.

  Add a schedule using microsoft project software amend wbs

Add a Schedule Using Microsoft Project software amend your WBS to include the schedule of time required to complete your project.

  Write a report with matlab simulations about the maximum

Partial feedback II: only SINR at each antenna element is known at the transmitter (full and quantized).

  Planning an it infrastructure audit for compliance

Note: Chapter 5 of the required textbook may be helpful in the completion of the assignment.

  What are the technical advantages of each

What are the technical advantages of each? What are the economic advantages of each? Why would people maintaining the system prefer one to the other?

  How many hits does the sequence exhibit

Assume LRU replacement policy, for each sequence, how many hits does the sequence exhibit?

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