9.2k views
0 votes
Write a java program to find the perimeter of a triangle with sides measuring 10cm, 14cm and 15 cm.

1 Answer

11 votes

Answer:

The code is shown below.

Step-by-step explanation:

Consider the provide information.

We need to find the perimeter of the triangle.

The perimeter of the triangle is the sum of all sides.

So the perimeter should be: 10 cm + 14 cm + 15 cm = 39 cm

Now we will write a Java program to find the perimeter.

public class MyClass {

public static void main(String args[]) {

int x=10;

int y=14;

int z=15;

int A=x+y+z;

System.out.println("The perimeter of the triangle is 10 cm + 14 cm + 15 cm = " + A+" cm");

}

}

Execute the program and you will get a result like this:

The perimeter of the triangle is 10 cm + 14 cm + 15 cm = 39 cm

Refer to the image for better understanding.

Write a java program to find the perimeter of a triangle with sides measuring 10cm-example-1
User Gideon Rosenthal
by
3.8k points