Write a program to check whether the given number is Happy Number or Not. #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.
ππ»Β 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