🔄Java Control Flow Programs
Control flow is the first thing to get comfortable with in Java: making decisions with if-else and switch, and repeating work with for and while loops. These short programs are ideal for beginners and for quick revision before an interview.68 programs · each with full code, output and a step-by-step explanation
Most Asked in Interviews
Determines whether a given character is a letter of the alphabet.
View Program →Determines whether a given character is a numeric digit.
View Program →Determines whether a given character is neither a letter nor a digit.
View Program →Determines whether a given letter is a vowel or a consonant.
View Program →Determines whether a given number is even or odd.
View Program →Determines whether a number is divisible by either 3 or 5.
View Program →Determines whether a number is divisible by both 5 and 11 at once.
View Program →Determines whether a number contains a zero digit anywhere in it.
View Program →Determines whether a number is exactly divisible by the sum of its own digits.
View Program →Determines whether the sum of the digits of a number's square equals the number itself.
View Program →Determines whether a number falls within a given lower and upper bound.
View Program →Determines whether a number is positive, negative, or zero.
View Program →Determines whether a given letter is uppercase or lowercase.
View Program →Determines whether three given side lengths can form a valid triangle.
View Program →Determines whether a person's age meets the minimum voting age.
View Program →Determines whether a character is a vowel using a switch statement with stacked case labels.
View Program →Determines whether a number is zero or non-zero.
View Program →Counts how many digits a given number has.
View Program →Counts how many whole numbers fall within a given inclusive range, using a loop.
View Program →Finds the leftmost digit of a given number.
View Program →Determines which of two given numbers is the larger.
View Program →Extracts the last digit of a number using the modulo operator.
View Program →Determines which of two given numbers is the smaller.
View Program →Classic loop-and-conditional warm-up exercise.
View Program →Looks up a short description for an already-known letter grade.
View Program →Displays a numbered menu, then performs the arithmetic operation the user selects.
View Program →Prints the cube of every number from 1 up to a given limit.
View Program →Prints the name of the day corresponding to a given number.
View Program →Prints every even number from 2 up to a given limit.
View Program →Prints the name of the month corresponding to a given number.
View Program →Prints the multiplication table of a given number, from 1 to 10.
View Program →Prints every number from 1 up to a given limit.
View Program →Prints every number from a given limit down to 1.
View Program →Prints every odd number from 1 up to a given limit.
View Program →Prints the square of every number from 1 up to a given limit.
View Program →Multiplies together every digit of a given number.
View Program →Removes the last digit of a number using integer division.
View Program →Looks up a menu item's name and price for a given menu choice.
View Program →Reverses the order of a number's digits.
View Program →Determines the season for a given month using grouped switch cases.
View Program →Performs basic arithmetic by switching directly on the operator symbol.
View Program →Adds together every digit of a given number.
View Program →Adds up every even number from 2 up to a given limit.
View Program →Adds up every number from 1 to a given limit.
View Program →Adds up every odd number from 1 up to a given limit.
View Program →Prints the driving action for a given traffic signal color.
View Program →Calculates the area of a shape by switching on its name.
View Program →Calculates an employee bonus using bracket-based bonus percentages.
View Program →Reduces a number down to a single digit by repeatedly summing its digits.
View Program →Calculates a discount and final payable amount using bracket-based discount percentages.
View Program →Calculates an electricity bill using simplified, illustrative tiered per-unit rates.
View Program →Calculates income tax using a simplified, illustrative slab structure.
View Program →Raises a number to a given exponent using a loop instead of Math.pow().
View Program →Determines whether a person meets the minimum age required to drive a given vehicle type.
View Program →Determines whether a given year is a leap year.
View Program →Determines whether the sum of a number's digits, each raised to its own position, equals the number itself.
View Program →Determines whether the sum of a number's digits equals the product of its digits.
View Program →Determines whether a given number is prime.
View Program →Classifies a triangle as equilateral, isosceles, or scalene based on its side lengths.
View Program →Converts a value between units by switching on the requested conversion type.
View Program →Converts an amount from a source currency to a target currency using illustrative fixed exchange rates.
View Program →Assigns a letter grade based on a student's marks.
View Program →Determines which of three given numbers is the largest.
View Program →Finds how many days a given month has, accounting for leap years.
View Program →Determines which of three given numbers is the smallest.
View Program →Converts each digit of a number into its spoken word form.
View Program →Prints the complete multiplication tables for every number from 1 to 10.
View Program →Performs a balance check, deposit, or withdrawal based on a menu choice.
View Program →