java

Write a program to check whether the given number is Happy Number or Not. #JAVA

Write a program to check whether the given number is Happy Number or Not. #JAVA

java

 

/*
QUESTION : Write a program to check whether the givemn number is Happy Number or Not.
           A happy number is a number in which the eventual sum of the square of digits of the number is equal to 1.
           Example :
                        28 = 2^2 + 8^2
                             4 + 64 = 68
                        68 = 6^2 + 8^2
                             36 + 64 = 100
                        100 = 1^2 + 0^2 + 0^2
                             1 + 0 + 0 = 1

*/

checkout Stone Paper Scissor Game code :Β click here

Write a program to input a String and Convert it in UPPER CASE and replace all vovel of String with the charactor followed by vovel : click here

 

package com.company;

import java.util.Scanner;

public class shivam_program_2
{

    static int SumOfSquares (int x)
    {
        int square=0 , temp=x , t ;
        while(temp>0)
        {
            t=temp/10;
            square = square + (t*t);
            temp = temp%10;
        }
        return (square);

    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("INPUT A NUMBER : ");
        int number = sc.nextInt();
        int dNumber = number;
        while(number > 9)
        {
            int sum = SumOfSquares(number);
            if(number > 9)
                number = sum;
            else
                break;
        }
        if(number == 1)
            System.out.println("Given number " + dNumber + " is happy number.");
        else
            System.out.println("Given number " + dNumber + " is not happy number.");

    }
}


Thanks Dosto for Reading this blog.

I think you all are definitely thinking of being connected with me.

Are you??
Yaa I know no-one is here but then also I provide my all social media links of my Digital Creation Tech DCode and my personal handles.
πŸ§‘β€πŸ’»πŸ§‘β€πŸ’» Social Media Links of Tech DCode :

πŸ‘‰πŸ»Β InstagramΒ :Β https://www.instagram.com/thetechdcode/
πŸ‘‰πŸ»Β Facebook PageΒ :Β https://www.facebook.com/thetechdcode
πŸ‘‰πŸ»Β TwitterΒ :Β https://twitter.com/thetechdcode
πŸ‘‰πŸ»Β TelegramΒ ChannelΒ :Β https://t.me/thetechdcode
πŸ‘‰πŸ»Β YouTubeΒ :Β https://www.youtube.com/channel/UCjJnEdeugftBwQ3yMuD4B_A
πŸ‘‰πŸ»Β Tech DCode LinktreeΒ :Β https://linktr.ee/thetechdcode
πŸ‘‰πŸ»Β My Personal HandlesΒ :Β https://linktr.ee/virtualshivamin

 

πŸ§‘β€πŸ’»πŸ§‘β€πŸ’»Β Social Media Links of SHIVAM SINGH (OWNER) :
πŸ‘‰πŸ»Β InstagramΒ :Β https://www.instagram.com/virtualshivamin/
πŸ‘‰πŸ»Β Facebook PageΒ :Β https://www.facebook.com/virtualshivamin/
πŸ‘‰πŸ»Β TwitterΒ :Β https://twitter.com/virtualshivamin/
πŸ‘‰πŸ»Β Personal LinktreeΒ :Β https://linktr.ee/virtualshivamin

Leave a Reply

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