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

  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