Homework please help!

shakerfawzi

New member
Joined
Feb 21, 2012
Messages
1
Programming Experience
Beginner
A palindrome is a number or a text phrase that reads the same backwards as forwards. For example, each of the following five-digit integers is a palindrome: 12321, 55555, 45554 and 11611. Write a program that reads in a five-digit integer and determines whether it is a palindrome. [Hint: Use the division and modulus operators to separate the number into its individual digits.] Note: Although this exercise talks about a five digit number, think about any length for the number.

im not sure whats the method required here, im guessing it has to be divided by 10 or something with a loop, but how do you apply that on C#.
Thanks!


 
You don't apply anything in C# if you don't even know what you're applying. The first step with any programming problem is to forget that it's a programming problem. Assume that all you have at your disposal is a pen and paper. What are the steps you perform under those circumstances? I'm not taking about high-level steps like "look at the number and see if it is the same backwards and forwards". I'm talking about low-level steps. If you don't know what those steps are then how can you possibly write code to perform them? The code is not the solution to the problem. It is an implementation of the solution. You need to solve the problem first, with no thought for programming. The set of steps you need to perform to get an answer is your algorithm and that is the solution. Once you have that algorithm, then you need to think about programming and how it can be implemented in your programming language of choice. You first write pseudo-code that implements our algorithm and then finally write real C# code that implements your pseudo-code. You don't simply go straight from a statement of the problem to code. We can help you with the last stage of that process if you need help but the whole point of the homework exercise is for you to use your brain to come up with an algorithm in the first place. If you can't do that then (I say this without malice) you don't deserve any marks for the assignment.
 
Back
Top Bottom