Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- /*
- =====================================================
- chapter 4: Loops
- Ex6: new number contains also reversed number
- =====================================================
- */
- public class MyProgram {
- public static void main(String[] args) {
- int num,count=0;
- int tmp,newNum=0;
- Scanner s=new Scanner(System.in);
- System.out.println("Enter a number: ");
- num=s.nextInt();
- tmp=num;
- while(tmp>0){
- newNum*=10;
- newNum+=tmp%10;
- tmp/=10;
- count++;
- }
- System.out.println(newNum);
- tmp= (int) Math.pow(10,count);
- tmp*=num;
- newNum+=tmp;
- System.out.println(newNum);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement