Posts

23. Display a number in words even with tailing 0.

package com.company ; import java.util.Scanner ; public class Main { public static void main ( String [] args ) { Scanner scan = new Scanner( System . in ) ; System . out .println( "Enter a Number" ) ; int n = scan .nextInt() ; int r ; String str = "" ; while ( n > 0 ) { r = n % 10 ; n = n / 10 ; str = str + r ; } System . out .println( str ) ; char c ; for ( int i = str .length()- 1 ; i >= 0 ; i --) { c = str .charAt( i ) ; switch ( c ) { case '0' : System . out .print( "Zero " ) ; break ; case '1' : System . out .print( "One " ) ; break ; case '2' : System . out .print( "Two " ) ; b

22. Reverse the number and find number is Pallindrome or not.

Pallindrome Number : - If the reverse of the number is eqal to original number then , the number is pallindrome. ex:- original number = 121 , reverse number = = 121 therefore 121 is pallindrome. int r , n ; int rev = 0 ; Scanner sc = new Scanner( System . in ) ; n = sc .nextInt() ; int number = n ; // to not lost original number while ( n > 0 ) { r = n % 10 ; rev = rev * 10 + r ; n = n / 10 ; } System . out .println( rev ) ; if ( rev == number ) { System . out .println( "Number is pallindrome" ) ; } else System . out .println( "Number is not pallindrome" ) ;   output :-                        121                                121                                Number is pallindrome

21. Number is Armstonrg or not

       Armstorng no : If the sum of the digits of the cube of number is equal to original number then it is armstorng number .       ex : take number n = 153;           if  3*3*3 + 5*5*5 + 1*1*1 = 153 (i.e. same  number ,n )           then, the number is Armstorng number. int n , r ; int sum = 0 ; Scanner sc = new Scanner( System . in ) ; n = sc .nextInt() ; int store = n // to store the number ; while ( n > 0 ) { r = n % 10 ; sum = sum + r * r * r ; //sum of the cuber of the number n = n / 10 ; } System . out .println( sum ) ; if ( sum == store ) { System . out .println( store + " is Armstrong no" ) ; } else System . out .println( store + " is not Armstrong no" ) ; } 23564 440 23564 is not Armstrong no Process finished with exit code 0           

Toast in Android.

 Toast in Android.  /    SNACKBAR / (for permanent display notification can be used) sdfsdf / Toast . makeText ( MainActivity . this , "login Successfully" , Toast . LENGTH_SHORT ) . show(); Context context = getApplicationContext (); CharSequence text = "Hello toast!" ; int duration = Toast . LENGTH_SHORT ; Toast toast = Toast . makeText ( context , text , duration ); toast . show (); FOR STYLEABLE TOAST First implement latest dependency. dependencies { implementation 'io.github.muddz:styleabletoast:2.4.0' } Next, go to values -> style -> create new <style name = "signuptoast"> layout < style name ="signupToast" > < item name ="stColorBackground" > #228B22 </ item > < item name ="stTextBold" > true </ item > < item name ="stTextColor" > #fff </ item > < item name ="stFont" > @font/retrofont </ item

while loop in java.

1. 1 2 3 4 5 6 7 8 9 10 int i = 1 ; while ( i <= 10 ) { System . out . println ( i ); i ++ ; } Q2. What will be output of this program. int x = 4 , y , z ; y =-- x ; z = x -- ; System . out . println ( x ); System . out . println ( y ); System . out . println ( z ); output:- 2 3 3 Q3. What will be output of this program. int x = 4 , y = 3 , z ; z = x -- - y ; System . out . println ( x ); System . out . println ( y ); System . out . println ( z ); output:- 3 3 1 Q4. What will be output of this program. package com.company ; import java.util.Scanner ; public class Main { public static void main ( String [] args ) { double i = 1.1 ; while ( i == 1.1 ) { System . out . println ( i ); i = i - 0.1 ; } } } output:- 1.1

How to implement animation or lottie files in android.

Image
 How to implement animation or lottie files in android. First of all, implement latest dependency in build.gradle file. implementation 'com.airbnb.android:lottie:4.1.0' //for lottie files Create one raw folder and put your JSON file in that Then in xml file put this code. < com.airbnb.lottie.LottieAnimationView android :id ="@+id/animationView" android :layout_width ="100dp" android :layout_height ="80dp" app :lottie_autoPlay ="true" app :lottie_loop ="true" app :lottie_rawRes ="@raw/lottie" /> //here put your own lottie file have a great day.  

how to reverse number

 HOW TO REVERSE A NUMBER take varible  int number; //to store original or to get quotient int rev; //to decrease the number int reverse_number = 0; //to store reverse number First take input from user.( number=5364 ) then run one while loop condition while(number>0) under loop rev = number%10; //we get rev =536 //take another variable reverse_number reverse_number = reverse_number*10+rev; //we get reverse_number= 4 number=number/10; //now number= 536 package com.company ; import java.util.Scanner ; public class Main { public static void main ( String [] args ) { // reverse number program int number , rev , reverse_number = 0 ; System . out . println ( "Enter a number" ); Scanner sc = new Scanner ( System . in ); number = sc . nextInt (); while ( number > 0 ) { rev = number % 10 ; reverse_number = reverse_number * 10 + rev ; number = number / 10 ; } System . out . println (

write a program to check whether a triangle is valid or not, when the threeangles of the triangle are entered through the keyboard. A triangle is valid if the sumof all the three angles is equal to 180 degrees

  /*write a program to check whether a triangle is valid or not, when the three angles of the triangle are entered through the keyboard. A triangle is valid if the sum of all the three angles is equal to 180 degrees. */ package com.company ; import javax.security.sasl. SaslClient ; import java.util.Scanner ; public class Main { public static void main ( String [] args ) { // write your code here int a , b , c , sum ; //angle of triangle Scanner angle = new Scanner ( System . in ); System . out . print ( "side a : " ); a = angle . nextInt (); System . out . print ( "side b : " ); b = angle . nextInt (); System . out . print ( "side c : " ); c = angle . nextInt (); //sum of angle of trinagle sum = a + b + c ; if ( sum == 180 ) { System . out . println ( "Triangle is valid" ); } else System . out . println (

HOW TO RETRIVED IMAGE FROM FIREBASE IN ANDROID

 HOW TO RETRIVED IMAGE FROM FIREBASE IN   ANDROID add Dependences in build.gradle file dependencies {     // Import the BoM for the Firebase platform     implementation platform ( 'com.google.firebase:firebase-bom:28.4.0' )     // Declare the dependency for the Cloud Storage library     // When using the BoM, you don't specify versions in Firebase library dependencies     implementation 'com.google.firebase:firebase-storage-latest version'//include latest version Add Imageview in xml to retrived image < ImageView android :id ="@+id/image" android :layout_width ="wrap_content" android :layout_height ="wrap_content" app :layout_constraintBottom_toBottomOf ="parent" app :layout_constraintEnd_toEndOf ="parent" app :layout_constraintStart_toStartOf ="parent" app :layout_constraintTop_toTopOf ="parent" app :layout_constraintVertical_bias ="0.966" android

Leap year or not in java.

  Formula to calculate leap year. Identify the year we want to know if its a leap year. We then divide the year by 4 to check if its evenly divisible. Then confirm that the year is not evenly divisible by 100. Check if the year is divisible by 400. If the year is evenly divisible by 4, then the year is a leap year. If the year is only evenly divisible by 100 and not evenly divisible by 400, then the year is not a leap year. package com.company ; import java.util.Scanner ; public class Main { public static void main ( String [] args ) { // write your code here int year ; Scanner sc = new Scanner ( System . in ); System . out . print ( "Enter year : " ); year = sc . nextInt (); if (( year % 4 == 0 ) && ( year % 100 != 0 ) && ( year % 400 != 0 )) { System . out . println ( year + " is Leap Year" ); } else { System . out . println ( year + " is Not L