Question: 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.
 Please make program basic, were only on while and for loops

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!