Java Programs
Special Two-Digit Number Program
import [Link].*;
class SpecialNumber
{
public static void main(String args[])
{
Scanner sc = new Scanner([Link]);
int n, first, second, sum, product, total;
[Link]("Enter a two-digit number: ");
n = [Link]();
first = n / 10;
second = n % 10;
sum = first + second;
product = first * second;
total = sum + product;
if(total == n)
[Link]("Special Number");
else
[Link]("Not a Special Number");
}
}
Leap Year Program
import [Link].*;
class LeapYear
{
public static void main(String args[])
{
Scanner sc = new Scanner([Link]);
int y;
[Link]("Enter year: ");
y = [Link]();
if(y % 400 == 0)
[Link]("Leap Year");
else if(y % 100 == 0)
[Link]("Not a Leap Year");
else if(y % 4 == 0)
[Link]("Leap Year");
else
[Link]("Not a Leap Year");
}
}
Nature of Roots of Quadratic Equation
import [Link].*;
class QuadraticRoots
{
public static void main(String args[])
{
Scanner sc = new Scanner([Link]);
int a, b, c, d;
[Link]("Enter value of a: ");
a = [Link]();
[Link]("Enter value of b: ");
b = [Link]();
[Link]("Enter value of c: ");
c = [Link]();
d = (b * b) - (4 * a * c);
if(d >= 0)
[Link]("Roots are real");
else
[Link]("Roots are imaginary");
}
}