Page 306 - IT-802_class_12
P. 306
System.out.println("Roots are real and unequal");
if (d == 0)
System.out.println("Roots are equal");
System.out.println("First root is " + root1);
System.out.println("Second root is " + root2);
}
}
Output:
Enter the value of a
2
Enter the value of b
3
Enter the value of c
-2
Roots are real and unequal
First root is 0.5
Second root is -2.0
26. Write a Java program to print the following pattern:
* * * * \
* * * \ *
* * \ * *
* \ * * *
\ * * * *
Ans. package com.mycompany.pattern;
class pattern
{
public static void main(String args[])
{
for (int i = 5; i >= 1; i--)
{
for (int j = 1; j <= 5; j++)
{
if (i==j)
System.out.print("\\ ");
else
System.out.print("* ");
}
System.out.println();
}
}
}
echnology
tion T
T
304 Touchpad Information Technology-XI-XII
ouchpad In
orma
f

