0

if and if-else statement:
you will have to write a program that reads a 4-digit positive integer from the user and prints out the following information on the screen:
1. Whether the positive integer is an odd or even number
2. (display) The odd digits of the integer
3. (display) The even digits of the integer
4. Whether the number reads the same forwards and backwards (e.g., 4004, 4444, etc.)
5. Whether all four digits are the same (e.g., 8888)

3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by freesoft_2000
1

you will have to write a program that reads a 4-digit positive integer from the user and prints out the following information on the screen:

Re-read your project assignment. Pay particular attention to the part that I bolded.

1

1st Part

public void posneg (String str1)
{
Convert the string to int
Divide it by 2,
if there is a remainder, its odd
if not even
}

second part

public void numposneg (String str2)
{
see the String api, there is an api that converts
the string to a char array

call posneg
}

third part

public void numposneg (String str2)
{
see the String api, there is an api that converts
the string to a char array

compare the first and last index only
}

last part

well you should be able to compare if
both number are equal

What would you kids do without richard west doing your homework

Richard West

Edited by freesoft_2000: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.