Saturday , 24 June 2017
Home » Disclaimer

Disclaimer

Important Disclaimer: The trademark “Java” belongs to Oracle, and we are in no way affiliated with or sponsored by Oracle or are marketing any services under their registered trademark. The term “Java” used in our website is descriptive, referring to the Java programming language.

This website is for educational purpose only and the word “Java” used in our websites (wherever they may be) have been used for educational purpose only.

4 comments

  1. program to check whether neon number or not

    • Here you go:

      import java.util.*;
      class Neon
      {
          int sumDig(int n)
          {
              int d = 0, sum = 0;
              while(n>0)
              {
                  d = n%10;
                  sum = sum + d;
                  n = n/10;
              }
              return sum;
          }
          
          public static void main()
          {
              Scanner sc = new Scanner(System.in);
              Neon ob = new Neon();
              System.out.print("Enter a number : ");
              int n = sc.nextInt();
              int sq = n*n;
              if(n == ob.sumDig(sq))
              {
                  System.out.println("The number is NEON");
              }
              else
              {
                  System.out.println("The number is Not NEON");
              }
          }
      }
      
  2. how to remove consecutive letters from a word
    like Input- abhishek
    Output-shek
    Input-abcdgf
    Output- gf

    • import java.io.*;
      class RemoveConsecutive
      {
          public static void main(String args[])throws IOException
          {
              BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
              System.out.print("Enter any word: "); // Inputting the word
              String s = br.readLine();
       
              s = s + " ";
              int l=s.length();
              String ans=""; // Variable to store the final result
              char ch1,ch2;
       
              for(int i=0; i<l-1; i++)
              {
                  ch1=s.charAt(i); // Extracting the first character
                  ch2=s.charAt(i+1); // Extracting the next character
      
                  if(ch2-ch1 == 1) // Condition for consecutive characters
                  {                  
                      i++;
                  }
                  else
                  {
                      ans = ans + ch1;
                  }
              }
              System.out.println("Word after removing consecutive characters = "+ans); // Printing the result
          }
      }

Leave a Reply

Your email address will not be published. Required fields are marked *

Open Chat
1
Close chat
Hello! Thanks for visiting us. Please press Start button to chat with our support :)

Start