Question

In: Computer Science

cpp program to read a triangle three sides and print" equilateral" when all the sides are...

cpp program to read a triangle three sides and print"

equilateral" when all the sides are equal and print "isosceles" when

two sides are equal and print "scalene" when all the sides are

different

Solutions

Expert Solution

thanks for the question, here is the complete program in C++

======================================================================

#include<iostream>

#include<cmath>

using namespace std;

int main(){

               

               

                double side_one, side_two, side_three;

                cout<<"Enter the sides of a triangle (separated by space): ";

                cin>>side_one>>side_two>>side_three;

               

               

                if(side_one>0 && side_two>0 && side_three>0) {

                               

               

                                if(abs(side_one-side_two)<=0.00001 && abs(side_one-side_three)<=0.00001){

                                               

                                                cout<<"Its an Equilateral Triangle.";

                                }

                               

                                else if (

                                                                (abs(side_one-side_two)<=0.00001 ||

                                                                abs(side_one-side_three)<=0.00001) ||

                                                                abs(side_three-side_two)<=0.00001){

                                                                               

                                                cout<<"Its an Isosceles Triangle.";

                                }

                                else{

                                               

                                                cout<<"Its an Scalene Triangle.";

                                }

                }

                else{

                               

                                cout<<"Error: Sides cannot be negative.";

                }

}

======================================================================


Related Solutions

Three charged particles are placed at each of three corners of an equilateral triangle whose sides...
Three charged particles are placed at each of three corners of an equilateral triangle whose sides are of length 2.1 cm . Two of the particles have a negative charge: q1 = -8.0 nC and q2 = -16.0 nC . The remaining particle has a positive charge, q3 = 8.0 nC . What is the net electric force acting on particle 3 due to particle 1 and particle 2? A) Find the net force ΣF⃗ 3 acting on particle 3...
An equilateral triangle is a triangle whose sides are equal. You are to write a class...
An equilateral triangle is a triangle whose sides are equal. You are to write a class called Triangle, using filenames triangle.h and triangle.cpp, that will allow the creation and handling of equilateral triangles, whose sides are integers in the range 1-39. Details: 1. The single constructor for the Triangle class should have 3 parameters: an integer size (required), which is the length of a side; a border character (optional, with a default of '#'); and a fill character (optional, with...
The  three charges are at the three vertices of an equilateral triangle ?( all angles are 60degrees)...
The  three charges are at the three vertices of an equilateral triangle ?( all angles are 60degrees) q 1  =  + 10.0 µC q 2 =  -  5 .0 nC q 3  = + 8 .0 nC Equilateral side of the triangle = 0.05 m. A. Draw forces acting on  q 1 by  q 2and q 3   B. find the components on X and Y axes . C. Use Pythagorean theorem to find the resultant . D. Use tangent to find the direction ( angle ) the resultant...
If equilateral triangles are constructed on the sides of any triangle, prove that the distances between...
If equilateral triangles are constructed on the sides of any triangle, prove that the distances between the vertices of the original triangle and the opposite vertices of the equilateral triangles are equal.
Argument A Since all triangles have three sides, and an isosceles triangle is a triangle, it...
Argument A Since all triangles have three sides, and an isosceles triangle is a triangle, it follows that an isosceles triangle has three sides. Argument a is: inductive/deductive; valid/invalid/strong/weak; sound/unsound/cogent/uncogent? Argument B There is a large crack in Philadelphia's Liberty Bell. From this, we can conclude that there was a defect in the bell's craftsmanship. Argument B is: inductive/deductive; valid/invalid/strong/weak; sound/unsound/cogent/uncogent? Argument C Paleontologists now agree that the Tyrannosaurus Rex was actually a peaceful, plant-eating dinosaur. Therefore, it is probably...
Write a program that accepts the lengths of three sides of a triangle as inputs. The...
Write a program that accepts the lengths of three sides of a triangle as inputs. The program output should indicate whether or not the triangle is a right triangle. Recall from the Pythagorean theorem that in a right triangle, the square of one side equals the sum of the squares of the other two sides. Use The triangle is a right triangle. and The triangle is not a right triangle. as your final outputs. An example of the program input...
Consider an equilateral triangle with sides measuring 1.0 m in length. At each point of the...
Consider an equilateral triangle with sides measuring 1.0 m in length. At each point of the triangle is a +2.0 ?C charge. Calculate the Coulomb force on each charge. Recall that forces are vectors and thus your answer will require a magnitude and direction for each of the three forces.
Complete the given C++ program (prob1.cpp) to read an array of integers, print the array, and...
Complete the given C++ program (prob1.cpp) to read an array of integers, print the array, and then find the index of the largest element in the array. You are to write two functions, printArray() and getIndexLargest(), which are called from the main function. printArray() outputs integers to std::cout with a space in between numbers and a newline at the end. getIndexLargest () returns the index of the largest element in the array. Recall that indexes start at 0. If there...
“Triangle Guessing” game in Python The program accepts the lengths of three (3) sides of a...
“Triangle Guessing” game in Python The program accepts the lengths of three (3) sides of a triangle as input . The program output should indicate if the triangle is a right triangle, an acute triangle, or an obtuse triangle. Make sure each side of the triangle is a positive integer. Use try/except for none positive integer input. validating the triangle. That is the sum of the lengths of any two sides of a triangle is greater than the length of...
3 charges, 8 µC each, are located on three vertices A, B, C of an equilateral triangle with sides 1 cm each.
  9). 3 charges, 8 µC each, are located on three vertices A, B, C of an equilateral triangle with sides 1 cm each. Another charge q is located at the mid point D of the side BC. Calculate q in micro Coulomb so that net force on the charge at A due to the charges at B, C and D is zero. 10). In a right angle triangle ABC, angle ABC is 90 Degree, AB = 2 m, and...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT