0% found this document useful (0 votes)
2 views2 pages

Java Programs ICSE

The document contains three Java programs: one that checks if a two-digit number is a special number by comparing the sum and product of its digits to the number itself, another that determines if a given year is a leap year based on specific conditions, and a third that evaluates the nature of roots of a quadratic equation by calculating the discriminant. Each program prompts the user for input and outputs the result accordingly. These examples demonstrate basic Java programming concepts including user input, arithmetic operations, and conditional statements.

Uploaded by

sonidevisingh20
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views2 pages

Java Programs ICSE

The document contains three Java programs: one that checks if a two-digit number is a special number by comparing the sum and product of its digits to the number itself, another that determines if a given year is a leap year based on specific conditions, and a third that evaluates the nature of roots of a quadratic equation by calculating the discriminant. Each program prompts the user for input and outputs the result accordingly. These examples demonstrate basic Java programming concepts including user input, arithmetic operations, and conditional statements.

Uploaded by

sonidevisingh20
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

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");
}
}

You might also like