Remove Vowels from a Sentence | Java Example

by Dinesh Thakur Category: Control Structures

Algorithm for Remove Vowels from a Sentence:

step 2: set char array c[]=word. to CharArray()

step 3: create new char array cc[] of size 80

Print Number from 1 to 10 Except 5

by Dinesh Thakur Category: Control Structures

Fibonacci Series Using Recursion in Java Example

by Dinesh Thakur Category: Control Structures

Fibonacci Series is series of Natural Number in the Sequence of: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55...., The first two number in Fibonacci series are 0 and 1, where next number is equivalent to sum of previous two number. in this example we use Recursion method , Recursion means calling the same function again and again to reduce the complexity of the problem solved.

Sum of Digits of a Number in Java Example

by Dinesh Thakur Category: Control Structures

In this program, we first input the number (Say num = 12345). Next the control reaches the while loop where it checks the condition (num>0) which is true as (12345>0) so the body of the loop is executed.

GCD of Two Numbers in Java Using While

by Dinesh Thakur Category: Control Structures

Algorithm for GCD of Two Numbers :

step 2: Repeat through step-5 while a not equals to 0

step 3: Set gcd=a

step 4: a=b%a

step 5:b=gcd

step 6: Print gcd

step 7: Exit

Java Calculate The Sum Of Only The Positive Numbers. Example

by Dinesh Thakur Category: Control Structures

This example computes the sum of positive numbers input by the user. When a negative number is input, the condition (num<0) become true and break statement is executed which leads to the termination of the while loop and the next statement following the loop is executed which displays the sum of positive numbers. The condition of the while loop always remains true as we have specified a non-zero value 1 which makes it run infinitely. The only way to exit this loop is to. use break statement.

Armstrong Number With in Range Java Example

by Dinesh Thakur Category: Control Structures

Algorithm for Armstrong Number with in Range:

step 2: Set count=0, b= 1

step 3: Repeat through step-11 while b less than or equals to range

step 4: Set sum=0

step 5: Set c=b

step 6: Repeat through step-9 while c greater than 0

Prime Numbers Between Range Java Example

by Dinesh Thakur Category: Control Structures

Algorithm For Prime Numbers between Range:

step 1: Set num=1

step 3: Repeat through step-9 while num less than or equals to range

step 4: Initialize b= 1, c=0

Switch Statement in Java Example

by Dinesh Thakur Category: Control Structures

When there is requirement of several branching i.e. if we need several if statements, it is better to use switch statement. In other words, switch is a variation of if statement which performs multiway branching.

Java Program Vowel or Not Example

by Dinesh Thakur Category: Control Structures

In the switch statement, since same statements has to be executed corresponding to different cases ('a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U') so we write the statements with the last case. The break statement causes the switch statement to terminate when any of the vowels is entered.

Odd Numbers from 1 To 100 in Java Example

by Dinesh Thakur Category: Control Structures

Highest Prime Number Within the Given Range Java Example.

by Dinesh Thakur Category: Control Structures

Algorithm for Highest Prime Number:

step 2: Set i== 1

step 3: Initialize j==2

step 4: Repeat through step-7 while j less than or equals to num

step 5: If j equals to num then Set i==num and goto 8

step 6: If (num mod)) equals to 0 then num==num-1

Java Nested For Loop Examples

by Dinesh Thakur Category: Control Structures

Like the nesting of if and other looping statements, the for loop can also be nested. In other words, we can have a for loop in the body of other for loop. There is no restriction on the level of nesting of loops but one should take care while nesting at multiple levels otherwise unexpected results may arise.

Right Angled Triangle in Java Example

by Dinesh Thakur Category: Control Structures

Algorithm for Right Angled Triangle:

step 1: Set i= 0,j 0, row=0,osc=0,var=0

step 3: Move to new line

step4: If (row>O) then execute following steps else goto step-23

step 5: Initialize isc=0

step 6: Print “*”

step 7: Initialize i=2

Write a Java program for triangle of asterisks with maximum length of user input

by Dinesh Thakur Category: Control Structures

Nested Switch Statements Java Example

by Dinesh Thakur Category: Control Structures

The switch statement is a multi-way decision making statement which selects one of several alternatives based on the value of an integer variable or expression. The switch statement is mainly used to replace multiple if-else-if statement. The if-else-if statement causes performance degradation as several conditions need to be evaluated before a particular condition is satisfied.

Fibonacci Series in Java Example

by Dinesh Thakur Category: Control Structures

Fibonacci series numbers are in the following Sequence: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144..., The first two number in Fibonacci series are 0 and 1, and each subsequent next number is the sum of the previous two Numbers.

Floyd Triangle in Java Example

by Dinesh Thakur Category: Control Structures

Algorithm for Floyd Triangle:

step 1: Set a= 1

step 3: Initialize i=0

step 4: Repeat through step-12 until i less than row

step 5: Initialize j=0

step 6: Repeat through step-10 until j less than or equals to i

step 7: Print a

Factorial of the Given Number in Java Example

by Dinesh Thakur Category: Control Structures

Factorial Number is the product of natural numbers from one to that particular number.  Mathematically, n! = 1 * 2 * 3 * .... * (n-1) * n

Reverse the Order of the Words in a Sentence in Java Example

by Dinesh Thakur Category: Control Structures

Stack-This class is a predefined class of java.uti1package. A stack represents a group of elements stored in LIFO (Last In Fast Out) order. This means that the element stored as a last element in the stack will be the first element to be removed from the stack.

Page 1 of 4

Dinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.

Related Articles