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

  Data redundancy and normalization

Discuss the relationship between data redundancy and normalization. What are the consequences if databases are not normalized? What problems is normalization addressing? Why is normalization crucial for effective database design and development?

  Considering that computing networks

TOPIC: CONSIDERING THAT COMPUTING NETWORKS ARE MORE AND MORE INTEGRATED IN ALL ASPECTS OF OUR LIVES, DISCUSS/PROPOSE A NEW/POSSIBLE IDEA ON HOW THESE NETWORKS CAN BE KEPT SAFE FROM HACKING, AND HOW TRANSMISSION OF DATA CAN BE SECURED END TO END..

  Order to qualify for the loan

Suppose that in order to qualify for the loan, the total monthly amount paid cannot exceed 30 percent of monthly income. What is the minimum monthly income needed to qualify for the loan?

  Find a 95% bootstrap percentile interval for the slope

Import from the data set Titanic the data on male passengers on the Titanic. The variable Survived is 1 if the passenger survived the sinking and 0 if the passenger died.

  What is steganography and what can it be used for

Which security protocols are predominantly used in Web-based electronic commerce?

  How a developer could attach issues to different model

You are developing a UML modeling tool. You are considering the integration of rationale into the tool. Describe how a developer could attach issues to different model elements. Draw a class diagram of the issue model and its association with mode..

  Use nand logic for this design

1. Design a counter that will count 3, 9, 6, 12, 1, 14 and automatically reset to 3.2. Design a counter that will count 0, 2, 3, 7, 10, 13, 15 and automatically reset to 0.

  Create a time trial program to compare the average execution

Create a time trial program to compare the average execution times of the Formula Node and the native LabVIEW Math Functions. This program will rquire a For Loop, a Flat Sequence structure, and a Case structure. The For Loop is required to run the ti..

  Develop a climate of trust and openness

Question: Managers at Range Resources use communication to develop a climate of trust and openness. Why is this especially important for energy companies, and what specific actions can managers take to enhance this communication approach?

  What is wrong with the hometown

What is wrong with the hometown?

  M uses the average and maximum error of the two values. c.

A Atmega128 is being used to monitor humidity inside test chamber 03. The device uses two sensors to have some fault tolerance.

  Why chain of custody must be followed in investigation

You are a computer forensics investigator for a law firm. The firm acquired a new client, a young woman who was fired. What is chain of custody and why must it be followed in investigations?

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