Note: Could you plz go this code and let me know if
u need any changes in this.Thank You
_________________
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
// Creatingan Exception class
class InvalidTriangleException : public exception {
private:
public:
// Zero argumented constructor
InvalidTriangleException()
{
}
virtual const char* what() const throw()
{
return "** Invalid Triangle **";
}
} myex;
class Triangle {
private:
//Declaring variables
int side1;
int side2;
int side3;
public:
//Parameterized constructor
Triangle(int side1, int side2, int side3)
{
if ((side1 + side2) > side3
&& (side2 + side3) > side1
&& (side3 + side1) > side2) {
this->side1 = side1;
this->side2 = side2;
this->side3 = side3;
}
else {
throw myex;
}
}
//Getters
int getSide1()
{
return side1;
}
int getSide2()
{
return side2;
}
int getSide3()
{
return side3;
}
//This function will calculate area of triangle
double area()
{
// calculating the semi perimeter
double s = (side1 + side2 + side3) / 2.0;
// calculating area
double area = sqrt(s * (s - side1) * (s - side2) * (s -
side3));
return area;
}
//This function will calculate perimeter of triangle
double perimeter()
{
// calculating perimeter
double peri = side1 + side2 + side3;
return peri;
}
};
int main()
{
//Declaring variables
int side1, side2, side3;
/* This loop continues to execute until
* the user enters valid sides of
triangle
*/
while (true) {
cout << "Triangle#1" << endl;
cout << "Enter side 1:";
cin >> side1;
cout << "Enter side 2:";
cin >> side2;
cout << "Enter side 3:";
cin >> side3;
try {
Triangle t(side1, side2, side3);
cout << "Area of Triangle :" << t.area() <<
endl;
cout << "Perimeter of Triangle :" << t.perimeter()
<< endl;
break;
}
catch (exception& myex) {
cout << myex.what() << endl;
continue;
}
}
return 0;
}
___________________________
Output:

_______________Could you plz rate me well.Thank You
Triangle stuff. Write a function IsValid(side1, side2, side3) that takes as argument 3 positive integers and...
(The Triangle class) Design a class named Triangle that extends the GeometricObject class. The Triangle class contains: - Three float data fields named side1, side2, and side3 to denote the three sides of the triangle. - A constructor that creates a triangle with the specified side1, side2, and side3 with default values 1.0. - The accessor methods for all three data fields. - A method named getArea() that returns the area of this triangle. - A method named getPerimeter() that...
Objective Extend the class GeometicShapes to include a Triangle class.. Background Reading ZyBooks Chapter 10 Task Create the following fields and methods for a Triangle class that extends the provided GeometricShapes class public class GeometricShapes { private String color = "red"; private boolean filled; private java.util.Date dateCreated; public GeometricShapes() { dateCreated = new java.util.Date(); } public GeometricShapes(String color, boolean filled) { dateCreated = new java.util.Date(); this.color = color; this.filled = filled; } public void setColor (String color)...
Please include comments in the program .The program must be able to be compiled.Design a class named Triangle that extends GeometricObject. This class contains:* Three double data fields named side1, side2, and side3 with default values 1.0 to denote the three sides of a triangle.* A no-arg constructor that creates a default triangle.* A constructor that creates a triangle with the specified side1, side2, and side3.* The accessor methods for all three data fields.* A method named getArea() that returns...
Welcome to the Triangles program Enter length 1: 3 Enter length 2: 5 Enter length 3: 5 Enter the base: 5 Enter the height: 8 --------------------- The triangle is Isosceles since it has two equal length sides. Isosceles triangle also has two equal angles The area is: 20 The permimeter is: 13 Continue? (y/n): y Enter length 1: 10 Enter length 2: 10 Enter length 3: 10 Enter the base: 10 Enter the height: 7 --------------------- The triangle is Equilateral...
(Need to complete the methods and pass a Junit test i can email them to you.) public class Triangle implements Comparable { /** * Stores the number of objects instantiated from the {@code Triangle} class */ private static int numTriangles; /** * The shortest side of the triangle */ private final double a; /** * The side of medium length of the triangle */ private final double b;...
Write a function that takes, as an argument, a list of positive integers and a target value, and returns the number of times that the target value appears in the list. Call this function problem1(myList, target). For example, >>>problem1([1,2,3,4,5,6,5,4,3], 5) should return 2, and >>>problem1([1,2,3,4,5,6,5,4,3], 7) should return 0.
(JAVA) Implement a Triangle class. Any triangle can be represented by its THREE sides. Therefore, your class will have THREE private member variables → side1, side2 and side3. Use the double data type to represent the triangle sides. In addition, please provide public methods that perform the following FIVE tasks: ▪ An input method that obtains the appropriate values for the three sides from the user. While entering the values of the three sides, please remember the triangle property that...
I am trying to write a Geometry.java program but Dr.Java is giving me errors and I dont know what I am doing wrong. import java.util.Scanner; /** This program demonstrates static methods */ public class Geometry { public static void main(String[] args) { int choice; // The user's choice double value = 0; // The method's return value char letter; // The user's Y or N decision double radius; // The radius of the circle double length; // The length of...
Write the java program: A right triangle can have sides whose lengths are all integers. The set of three integer values for the length of the sides of a triangle is called a Pythagorean triple. The length of the three sides must satisfy the relationship that the sum of the squares of the sides is equal to the square of the hypotenuse. Write a Java application that prompts the user for an integer that represents the largest side value and...
Write the java program: A right triangle can have sides whose lengths are all integers. The set of three integer values for the length of the sides of a triangle is called a Pythagorean triple. The length of the three sides must satisfy the relationship that the sum of the squares of the sides is equal to the square of the hypotenuse. Write a Java application that prompts the user for an integer that represents the largest side value and...