Module 1: Basic Java Programs
Fundamental Java programs to get started with syntax, I/O, operators, and basic problem solving.
20 program solutions
Program Solutions
Hello World
Print "Hello, World!" on the console using Java.
Add Two Numbers
Read two numbers from the user, add them, and display the result.
Swap Two Numbers
Swap the values of two variables using a temporary variable.
Find ASCII Value of a Character
Read a character and print its ASCII value.
Even or Odd Number
Check whether a given integer is even or odd.
Largest of Two Numbers
Find the largest of two numbers using if-else.
Largest of Three Numbers
Find the largest of three numbers using conditional statements.
Positive or Negative Number
Check whether a number is positive, negative, or zero.
Area of Circle
Calculate the area of a circle given its radius.
Area of Rectangle
Calculate the area of a rectangle given its length and breadth.
Area of Triangle
Calculate the area of a triangle using base and height.
Simple Interest
Calculate simple interest given principal, rate, and time.
Compound Interest
Calculate compound interest using principal, rate, time, and compounding frequency.
Celsius to Fahrenheit
Convert temperature from Celsius to Fahrenheit.
Sum of N Natural Numbers
Calculate the sum of first N natural numbers using formula.
Power without Math.pow()
Compute a^b using a loop instead of Math.pow().
ASCII to Character
Convert an integer ASCII code to its corresponding character.
Character to ASCII
Convert a character to its ASCII code.
Convert Seconds to Hours and Minutes
Convert total seconds into hours, minutes, and remaining seconds.
Gross Salary Calculation
Calculate gross salary using basic salary, HRA, and DA.