INSTRUCTIONS Write a Triangle class.The submission should contain two files (a s
ID: 3530285 • Letter: I
Question
INSTRUCTIONS
Write a Triangle class.The submission should contain two files (a specification and implementation file).For the sake of simplicity, we will assume that the triangle being dealt with is right (one of the internal angle measures is exactly 90 degrees).The class should contain private data members (doubles) that hold information about the length of the three sides of the triangle (opposite, adjacent, and hypotenuse), area, and perimeter.Public interfaces should be provided that allow the client code to set values for the opposite and adjacent side of the triangle.Logic should be included in the setters to update the length of the hypotenuse, the area, and the perimeter.Getter methods should be provided to provide read-only access to all of the private data members.Finally, a display method should be included that displays a neat picture of the rectangle (scale is not an issue) with labels indicating the length of each side, the area, and the perimeter.Please be creative when writing the display method and make your output match the provided output as closely as possible (you will need to make use of the <iomanip> features to accomplish this).You class should properly interface with the provided driver code.You MAY NOT modify the driver code (except the #define statements).Please adhere to all established coding conventions concerning classes.
driver.cpp
#include <iostream>
#include "Triangle.h"
using namespace std;
#define OPPOSITE 3
#define ADJACENT 4
int main() {
// instantiate the class
Triangle myTriangle;
// load the values
myTriangle.setOppositeLength(OPPOSITE);
myTriangle.setAdjacentLength(ADJACENT);
// display the rectangle
myTriangle.DisplayTriangle();
return 0;
}
HINTS
Use a precision level of 2 when displaying the results.This is acceptable and will help you keep you data lined up.You will need to calculate square roots to properly populate the class with valid hypotenuse information.This function sqrt() can be used to accomplish this.sqrt() can be located in the
Explanation / Answer
you can use this java program using GRAPHIC USE INTERFACE code goes like this import java.io.*; import java.util.*; import java.awt.*; import java.awt.event.*; import javax.swing.*; import cmath.h: public class Triangle implements jpanel { public static void main(String[] args) { System.out.println("Provided triangle sides are "); for (int i=0;i
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.