Page 108 - CA_Blue( J )_Class10
P. 108
13 else if (d == 0.0)
14 {
15 r1 = -b / (2.0 * a);
16 System.out.println("The roots have same value: " + r1);
17 }
18 else
19 {
20 System.out.println("The roots are imaginary.");
21 }
22 }
23 }
You will get the following output:
Program 4 To input the three sides of a triangle and calculate the area and perimeter of the scalene triangle.
Formula to calculate the area is: s(s-a) (s-b) (s-c) where s = (a + b + c)
2
Formula to calculate the perimeter is: a + b + c
1 import java.util.*;
2 class scalene_triangle
3 {
4 public static void main ()
5 {
6 Scanner sc= new Scanner (System.in);
7 double a,b,c,s=0.0,area,perimeter;
8 System.out.println("Enter the three sides of the triangle: ");
9 a=sc.nextDouble();
10 b=sc.nextDouble();
11 c=sc.nextDouble();
106106 Touchpad Computer Applications-X

