Appropriate element of the array

Assignment Help Basic Computer Science
Reference no: EM131578500

A Palindrome is a word (or a number) that reads the same backwards. In this assignment you will be writing a program that repeatedly prompts a user for a positive integer number and tests whether the number is a palindrome. Your program should convert the integer value given by the user into an int array storing each digit of the number in the appropriate element of the array. It should then check to see whether the array is a palindrome. Your program should follow the guidelines given below.

1. Compose a method called getSize( int num ) that takes an integer number as input argument and returns the number of digits in that number. For e.g., getSize( 234 ) should return 3 and getSize( 76 ) should return 2.

2. Compose a method called fillArray( int num, int[] intArray ) that takes an integer number and an integer array argument and fills the array with the appropriate digits of the number. For e.g., calling the above method fillArray( 87432, intArray ) would set intArray[0] to the value 8, intArray[1] to 7, ..., and intArray[4] to 2.

3. Compose a boolean method called isPalindrome( int[] intArray ) that takes an integer array argument and returns the value true if the array is a palindrome else returns false.

4. Finally, write the main method that prompts the user repeatedly for an integer number, uses the getSize method to find out the number of digits in that number, allocates the int array for that size, calls the method fillArray to populate the array with the digits of the number, calls the isPalindrome method to find out whether the array is a palindrome, and prints out the result. Your program should terminate when the user enters -99.

Notes:

1. In Java you can allocate an array using a variable for the size, i.e., int[] intArray = new int[size]; where size is an int variable.

2. You SHOULD NOT use any methods from either the String or the Arrays class in your program.

Compose the program in JOption pane.

Reference no: EM131578500

Questions Cloud

What should have been done differently and why : Who owns the property? What is each person's ownership interest? Who has control over the venture? What should have been done differently and why?
One could argue that the internet : One could argue that the Internet provides all the redundant routing and alternate sites an enterprise needs.
Are the given two events equally likely : Event 1 consists of drawing an ace and a king when you draw two cards from among the thirteen spades in a deck of cards and event 2 consists of drawing an ace.
Identify factors that may lead to conflict you can manage : Everyone should know that certain behaviors are not permissible at work places, and resolutions of conflict should begin from lower levels.
Appropriate element of the array : Your program should convert the integer value given by the user into an int array storing each digit of the number in the appropriate element of the array.
Probability that the two shapes we see on top are the same : A die is made of a cube with a square painted on one side, a circle on two sides, and a triangle on three sides.
Summarize the events of a recent accounting scandal : Summarize the events of a recent accounting scandal. Identify how the illegal/unethical act was detected
Various types of information contained there : Visit the Web site of an on-line vendor. Browse the online catalog and note the various types of information contained there.
Discuss the importance of netiquette in communication : Discuss importance of netiquette in professional electronic communication. Explain three possible repercussions of failing to use netiquette in communication.

Reviews

Write a Review

Basic Computer Science Questions & Answers

  We will compare the performance of a vector processor

In this problem, we will compare the performance of a vector processor with a hybrid system that contains a scalar processor and a GPU-based coprocessor.

  Conduct cyber warfare or covert cyber operations

Should a country conduct cyber warfare or covert cyber operations against its adversaries? Why or why not?

  Algorithm to sort the array of strings named colors

Use the remove_if algorithm to remove from the vector of strings named colors all of the strings that start with "bl". Function startsWithBL returns true if its argument string starts with "bl". Store theiterator that the algorithm returns in newL..

  What is the significance of using the access modifier

What is the significance of using the access modifier private with instance variables?

  Draw an entity-relationship diagram

Draw an entity-relationship diagram that describes the following business environment. Must be done by hand, on paper. Not on the computer and include relationship types, ( i.e. Many to many, one to one represented by crows feet etc.

  Entity relationship diagram for flapper dumpling

Draw an entity relationship diagram for Flapper Dumpling.

  Difference between active and a passive state for an object

What strategy would you propose for defining subsystems for a collection of classes?

  Find the error in the following pseudocode

Find the error in the following pseudocode. Constant Real GRAVITY = 9.81 Display "Rates of acceleration of an object in free fall:"

  Professional behavioral assessment

To date, you have taken a deep look at yourself through the lens of MBTI, a professional behavioral assessment. You have also assessed your own skills and personal traits. You have transferred these, along with some biographic material to a resume..

  What is the output of the short program below

Explain your answer. class Program { static String location; static DateTime time; static void Main() { Console.WriteLine(location == null ? "location is null" : location); Console.WriteLine(time == null ? "time is null" : time.ToString()); } }

  Give an estimate of saving in computations in terms of m l

Which algorithm is better if we wish to compute all points of the DFT? What happens if we want to compute only the points X(0), X(1), X(2), and X(3)? Establish a rule to choose between DIT and DIF pruning depending on the values of M and L.

  Quotas based on volumes or by users

An administrator can set up disk quotas based on volumes or by users. Each volume must have its own separate set of disk quotas.

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