| Ask a Question | Answer a Question! | 

 Submitting your question... 
 
 
ResFinder - Thousands of Practice Papers
| if (n == 0) 
           { 
               n = sum; 
               sum = 0; 
           } 
I cannot find any use of these lines in magic number progrma
Can anyone pllease explain. |  | 
| asked by Bitthal Maheshwari (bitthal04) 6 years ago | 
| 5 | 
| String res = str.replace(" " , "");  this works
 but this String res = str.replace(' ' , ''); do not work
Why? if they should be character then ther should be ' ' |  | 
| asked by Ansh Anand (teleansh) 6 years ago | 
| 1 | 
|  + 2 more questions by teleansh    
| Why can't we replace a character with empty character. I want to remove spaces from sentence and using
ch = str.charAt(i);
            str = str.replace( ch , "");
but it is showing error |  |  
| asked by Ansh Anand (teleansh) 6 years ago |  
| 0 |  
| Why it is not working. It is a program for Duck Number
import java.util.Scanner;
public class magic
{
    public static void main (String args[])
    {
        Scanner sc = new Scanner(System.in);
        System.out.println("ENTER NO TO CHECK");
        int num = sc.nextInt();
        String str = Integer.toString(num);
        int len = str.length();
        int count = 0;
        int i;
        for(i=0 ; i <len ; i++)
        {
            if ( str.charAt(i) == '0')
            count ++;
        }
        
        
        if(count > 0 && str.charAt(0) != '0')
        System.out.println("It is a Duck Number");
        else
        System.out.println("It is not a Duck Number");
            
    }
} |  |  
| asked by Ansh Anand (teleansh) 6 years ago |  
| 2 |  
| Anyone from Mumbai |  |  
| asked by Tubhyam Mehta (tirth7683) 6 years ago |  
| 3 |  
| I'm so glad I found ResPaper! Nice to have mates from over the country(well mainly Bangalore and Mumbai but yeah :P)
Well, I should be saying all this on the last board exam but well passion, mistress of desires and it sways it to the mood of what it likes or loathes. |  |  
| asked by Aquaman- King of the Seven Seas (shauns) 6 years ago |  
| 3 |  
| any one here commercial applications.... |  |  
| asked by jesusavari 6 years ago |  
| 0 |  
| If there is difference between two things asked for 2 marks and we have only one point are examples accepted? |  |  
| asked by Anvaya Juvekar (anvaya) 6 years ago |  
| 1 |  
| What is the scope of local,instance & class variable? |  |  
| asked by Jeevan Kumar (jeevanms) 6 years ago |  
| 2 |  
| Hi |  |  
| asked by ... (sam307) 6 years ago |  
| 2 |  
| Accept a no. from the user and find if it is a fascinating number.( FASCINATING NUMBER : When a number( 3 digit or more) is multiplied by 2 and 3 ,and when both these products are concatenated with the original number all digits from 1 to 9 are present exactly once, regardless of the number of zeroes) |  |  
| asked by Deeksha (deeksha9) 6 years ago |  
| 3 |  
| hi guys these are two answers to the disarmium question everyone has been bothered about- without using string functions
import java.util.Scanner;
public class disarmy1
{
    void hello()
    {  Scanner in = new Scanner(System.in);
        System.out.println("enter the number ahole");
        int s = in.nextInt();
        int a = s;
        int b=s;
        int d=0;//to find the digits
        int c=0;//to count the number of digits
        int i,e=0,sum=0;
        while(s>0)
        {  d= s%10;
            c++;
            s=s/10;
        }
        for(i=c;i>=1;i--)
        { 
            
            
          e= a%10;
           sum = sum+ (int)(Math.pow(e,i));//since i is equal to number of digits
            a=a/10;
        
       }
       if(sum==b)
       System.out.println("disarmium number");
       else
       System.out.println("not");
    }
}
//THIS IS THE SECOND ANSWER TO THE QUESTION WHICH IS A LITTLE HARDER TO COPREHEND 
import java.util.Scanner;
public class disarmy2
{
    void hello()
    {
        //this is using arrays
         Scanner in = new Scanner(System.in);
        System.out.println("enter the number ahole");
        int s = in.nextInt();
        int n =s;
        int q=s;
        int d=0;
        int i;
        int c=0;
        int x=0;
        int sum=0;
        while(s>0)//to find the number of digits the number has
        {d = s%10;
            c++;
            s=s/10;
        }
        int a[]= new int[c];
        for(i=0;i<c;i++)//to put all these digits into an array
        {
            x=n%10;
            a[i]= x;
            n=n/10;
        }
        for(i=c-1;i>=1;i--)//taking array from the last element and adding the power of index+1 of that number to sum
        {
            sum = sum+ (int)Math.pow(a[i],i+1);
        }
        if(sum==q)
        System.out.println("disarmium");
        else
        System.out.println(" not");
    }
    
} |  |  
| asked by Sankhya Gowda (taankkkkk) 6 years ago |  
| 2 |  
 |