Trending ▼   ResFinder  

ICSE − Q & A

ICSE
Indian Certificate of Secondary Education (ICSE), New Delhi
+Fave Message

Ask a Question

Answer a Question!

ResFinder - Thousands of Practice Papers

Guys try this logic for Fascinating Number; I've broken down the program into bits so that it'll be easier to comprehend. Its done using Strings,Arrays,Sorting and checking...

import java.util.*;
class Fascinating
{
    public static void main()
    {
        //accepting
        System.out.println("Enter Number: ");
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        String temp=Integer.toString(n*1)+Integer.toString(n*2)+Integer.toString(n*3);
        int[]a={1,2,3,4,5,6,7,8,9};
        char[]ch=temp.toCharArray();
        
        //sorting
        for(int i=0;i<ch.length-1;i++)
        {
            for(int j=0;j<ch.length-i-1;j++)
            {
                if(ch[j]>ch[j+1])
                {
                    char aa=ch[j];
                    ch[j]=ch[j+1];
                    ch[j+1]=aa;
                }
            }
        }
        
        //counting
        boolean b=false;
        int count=0;
        for(int i=0;i<ch.length;i++)
        {
            
            if(ch[i]==0)
            continue;
            
            else 
            {
                if(((int)ch[i]-48)==a[i]){
                b=true;
                count++;
            }
                
                else 
                b=false;
            }
        }
        
        //printing
		if(b==true&&count==9)
		    System.out.println("Fascinating Number!");
		else
		System.out.println("Not Fascinating Number!");
}
}
asked by Rochan HM (rochana_hm3) 8 years ago
2

Other Questions on This Topic

When is the 2026 icse exam?
asked by Yogesh (yogesh) 128 days ago
1

+ 3 more questions by yogesh  

https://www.respaper.com/
asked by Sujata Kundu (mumpi_1989) 186 days ago
1

+ 3 more questions by mumpi_1989  

i'm unable to download papers
asked by Tsa (rajpurohit14) 276 days ago
1
Class 9 final question paper
asked by Armaan Mandal (arms10) 301 days ago
0
How to contact respaper
asked by Insha Naz Fatima (sarahmeh) 323 days ago
1

+ 2 more questions by sarahmeh  

8th Icse question papers
asked by Aparna Narayan (aparna1974) 1 year ago
1
What's up people? Does anyone I know ever visit this place? If yes please just hit me up with a "hi" I would love to chat haha... Take care everyone :))
asked by Anshika Jaiswal (anshika28) 1 year ago
4
I've got an endsem exam in an hour but all I am doing is reading old threads on res. 🥲
asked by Nisarg Bhavsar (nisarg71) 1 year ago
3
Hlooo..itzz been longgg...ICSE 2018 batch anybody??
asked by Snigdha (silver2002) 1 year ago
3

Next Page >>

ICSE chat

© 2010 - 2025 ResPaper. Terms of ServiceContact Us Advertise with us