✅ Java Practice Programs (No Loops / No If-Else)
✅ Java Practice Programs (No Loops / No If-Else)
Beginner-friendly Java practice programs that avoid loops and if-else
, focusing only on fundamentals like data types, variables, assignments, initialization, and simple operators.
-
๐ Print your name and age
-
➕ Add two integers and print the result
-
➖ Subtract two float numbers and print the result
-
✖️ Multiply two double values and print the result
-
➗ Divide two integers and print the quotient and remainder
-
๐ Swap two numbers using a third variable
-
๐ Swap two numbers without using a third variable
-
๐ Assign values to
byte
,short
,int
,long
,float
, anddouble
and print them -
๐ Concatenate and print first name and last name
-
๐ Calculate area of a rectangle using
length * breadth
-
⚪ Calculate area of a circle (
ฯ * radius * radius
) -
๐ก️ Convert temperature from Celsius to Fahrenheit
-
๐ก️ Convert temperature from Fahrenheit to Celsius
-
✅ Check if a number is greater than 10 using logical AND (
&&
) operator -
๐ Check if a number is less than 5 or greater than 15 using logical OR (
||
) operator -
๐ฐ Calculate the simple interest (
(P * T * R) / 100
) -
๐ Assign a string and add (concatenate) number 25 to it and print
-
๐ Assign a value to a boolean variable based on an expression and print it
-
⚖️ Find the average of three numbers and print the result
-
๐ข Print the square and cube of a number
๐ String-Specific Programs
-
๐ข Find and print the length of a given string
-
๐ Convert a string to uppercase and print it
-
๐ก Convert a string to lowercase and print it
-
✂️ Extract and print the first 3 characters (substring) from a string
-
➕ Concatenate two strings with a space in between and print the result
Comments
Post a Comment