Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please make program basic, were only on while and for loops Write a Java program that reads an integer N in the range 4 to

Please make program basic, were only on while and for loops
Write a Java program that reads an integer N in the range 4 to 8 and then another integer M that
has N digits. For example, N=4 and M=6487. Another example is N=6 and M=379565.
Your program must first validate N to be in the range 4 to 8 and M contains exactly N digits. To
check the latter, make sure that MMNMM10N(10,N)MK=0K=K**10+M%10M=M10MKM10N-1. Now, reverse the integer M and print both M
and its reverse.
Programming requirements
You must read both N and M and you must validate both of them.
You must print both M and its reverse.
Hint: To compute 10N, use Math.pow (10,N).
To compute the reverse ofan integer M, you can use the following algorithm:
(a) Declare an integer K=0.
(b) Set K=K**10+M%10.
(c) Set M=M10.
(d) Repeat the last two septs until M becomes zero. At that time, K will become the reversed
integer ofM.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Harness The Power Of Big Data The IBM Big Data Platform

Authors: Paul Zikopoulos, David Corrigan James Giles Thomas Deutsch Krishnan Parasuraman Dirk DeRoos Paul Zikopoulos

1st Edition

0071808183, 9780071808187

More Books

Students also viewed these Databases questions

Question

According to the law of supply, the supply curve has a what slope

Answered: 1 week ago