Posts

Showing posts from May, 2021

Check vowel or constant in java

10. Check vowel or constant in java package com.company ; import java.util.Scanner ; public class Main { public static void main ( String [] args ) { // write your code here Scanner sc = new Scanner ( System . in ); System . out . println ( "Enter alphabet to check alphabet is vowel or constant" ); char alphabet = sc . next (). charAt ( 0 ); if ( alphabet == 'a' || alphabet == 'e' || alphabet == 'i' || alphabet == 'o' || alphabet == 'u' ) { System . out . println ( alphabet + " is vowel" ); } else System . out . println ( alphabet + " is constant" ); } } output:- h is constant Process finished with exit code 0

convert int to char in java

 9. convert int to char in java package com.company ; import java.util.Scanner ; public class Main { public static void main ( String [] args ) { // write your code here int a ; Scanner sc = new Scanner ( System . in ); System . out . println ( "Enter a number : " ); a = sc . nextInt (); char b = ( char ) a ; /*there might be a loss of data while converting from int to car. so ,we are using (char) to specify that a should be converted to character*/ System . out . println ( b ); } } output:- Enter a number : 80 P Process finished with exit code 0

Number is even or odd in java

  8 . Number is even or odd in java package com.company ; import java.util.Scanner ; public class Main { public static void main ( String [] args ) { // write your code here int a ; Scanner sc = new Scanner ( System . in ); System . out . println ( "Find number is even or odd" ); System . out . print ( "Enter a number : " ); a = sc . nextInt (); if ( a % 2 == 0 ) { System . out . println ( "Even" ); } else System . out . println ( "Odd" ); } } output:- Find number is even or odd Enter a number : 23 Odd Process finished with exit code 0

Typecasting

  Typecasting Typecasting:- typecasting help to convert one data type to another data type //Typecasting package com.company ; public class Main { public static void main ( String [] args ) { // write your code here //int type variable int a = 33 ; System . out . println ( "int variable : " + a ); //convert int into double double c = a ; System . out . println ( "double variable is : " + c ); } } output:- int variable : 33 double variable is : 33.0 Process finished with exit code 0

find quotient and remainder in java

  find quotient and remainder //find quotient and remainder package com.company ; import java.util.Scanner ; public class Main { public static void main ( String [] args ) { int dividend , divisor , quotient , remainder ; Scanner ddqr = new Scanner( System . in ) ; System . out .print( "Enter dividend : " ) ; dividend = ddqr .nextInt() ; System . out .print( "Enter divisor : " ) ; divisor = ddqr .nextInt() ; quotient = dividend / divisor ; System . out .println( "Quotient is : " + quotient ) ; remainder = dividend % divisor ; System . out .println( "Remainder is : " + remainder ) ; } } output:- Enter dividend : 15 Enter divisor : 4 Quotient is : 3 Remainder is : 3 Process finished with exit code 0

Round Number to n Decimal Place

2. Round Number to n Decimal Place //here we used format() method to print the given decimal number to 3 decimal places //The format string %.3f specifies to print the number to 3 decimal places. //Round number to n decimal place package com.company ; import java.util.Stack ; public class Main { public static void main ( String [] args ) { //dicimal number double num = 5.873324 ; //print number to 3 decimal places System . out .format( "%.5f" , num ) ; } }

swapping of two number in java with algorithm.

Image
  swapping of two number.   algorithm for swapping of two number. first take two input from user as (a ,b) then create one temporary variable as (temp) and then store the value of a into temporary variable as (temp=a) so that value of a not change and then assign the value as (a=b; and b=temp) and lastly print the value of a and b   program in java    //swapping of two number package com.company ; import java.util.Scanner ; import java.io. * ; public class Main { public static void main ( String [] args ) { Scanner input = new Scanner ( System . in ); System . out . println ( "Enter two number " ); int a,b; int temp; // here we use temporary varaiable to store data System . out . println ( "first : " ); a = input. nextInt (); System . out . println ( "second : " ); b = input. nextInt (); temp = a; a = b; b = temp; System . out . println ( "After swappi

AREA AND PERIMETER OF CIRCLE

Image
     AREA AND PERIMETER OF CIRCLE //find area of circle and perimeter of circle. package com.company ; import java.util.Scanner ; import java.io. * ; public class Main { public static void main ( String [] args ) { float radius ; Scanner input = new Scanner ( System . in ); System . out . print ( "Enter radius of circle : " ); radius = input . nextFloat (); double area , perimeter ; area = Math . PI * ( radius * radius ); perimeter = 2 * Math . PI * radius ; System . out . println ( "Area of circle is : " + area ); System . out . println ( "Perimeter of circle is :" + perimeter ); } } Enter radius of circle : 12 12.0 Area of circle is : 452.3893421169302 Perimeter of circle is :75.39822368615503 Process finished with exit code 0 Sharaddha Nand Pandey Welcome You
  Write a Java program to display the following pattern. Sample Pattern : J a v v a J a a v v a a J J aaaaa V V aaaaa JJ a a V a a package com.company ; import java.util.Scanner ; public class Main { public static void main ( String [] args ) { // write your code here System . out . println ( " J A V V A" ); System . out . println ( " J A A V V A A" ); System . out . println ( "J J AAAAAA V V AAAAAAA" ); System . out . println ( " JJ A A V A A" ); } } J A V V A J A A V V A A J J AAAAAA V V AAAAAAA JJ A A V A A Process finished with exit code 0

Addition ,multiplication ,division ,subtraction of a number.

Addition ,multiplication ,division ,subtraction of a number. //Addition ,multiplication ,division ,subtraction of a number. package com.company ; import java.util.Scanner ; public class Main { public static void main ( String [] args ) { // write your code here float a , b , sum , sub , mul , div , mod ; Scanner input = new Scanner ( System . in ); System . out . println ( "Enter two number " ); System . out . print ( "fist number : " ); a = input . nextFloat (); System . out . print ( "second number : " ); b = input . nextFloat (); sum = a + b ; sub = a - b ; mul = a * b ; div = a / b ; mod = a % b ; System . out . println ( "Sum of two number is : " + sum ); System . out . println ( "Product of two number is : " + mul ); System . out . println ( "Difference of two number : " + sub ); System .

Multiplication table in java

Home Java Android Development Contact Resources MULTIPLICATION TABLE IN JAVA 😊😌😎 package com.company ; import java.util.Scanner ; public class Main { public static void main ( String [] args ) { // write your code here int table ; Scanner table1 = new Scanner ( System . in ); System . out . print ( "Enter Table number : " ); table = table1 . nextInt (); for ( int i = 1 ; i <= 10 ; i ++ ) { System . out . println ( table + " x " + i + " = " + table * i ); } } } Enter Table number : 12 12 x 1 = 12 12 x 2 = 24 12 x 3 = 36 12 x 4 = 48 12 x 5 = 60 12 x 6 = 72 12 x 7 = 84 12 x 8 = 96 12 x 9 = 108 12 x 10 = 120 Process finished with exit code 0 HAVE A GOOD DAY 😎
  package com.company ; import java.util.Scanner ; public class Main { public static void main ( String [] args ) { // write your code here float salary , Da , Hr , allowance , TotalDaHr , grossSalary ; Scanner Salary = new Scanner ( System . in ); System . out . print ( "Ramesh Enter your basic Salary : " ); salary = Salary . nextFloat (); System . out . print ( "Enter Your dearness allowance(in %) : " ); Da = Salary . nextFloat (); System . out . print ( "Enter your house rent(in %) : " ); Hr = Salary . nextFloat (); allowance = Da + Hr ; TotalDaHr = ( allowance / 100 ) * salary ; grossSalary = salary - TotalDaHr ; float Dm , Hm ; Dm = ( Da / 100 ) * salary ; Hm = ( Hr / 100 ) * salary ; System . out . println ( "Ramesh Dearness allowance(in Rupee) : " + Dm ); System . out . println ( "Ramesh House rent (in