- File Input & Output
CS160: Foundations in Programming
Create the following instance variables and methods inside your Triangle class
Height, Base, and Area should be formatted to 2 decimal places.
- Two instance variables of type double named height and base.
- A constructor that takes two parameters and assigns those values to the instance variables.
- a private non-static method called area that has no parameters and returns a double
- a toString method that returns the following:
Triangle, (Height: #, Base: #), Area: #
To make sure your Triangle class is printing what you want it to print. Create a Triangle object in your main method using the following code:
Triangle shape = new Triangle(5, 10);
© 2015 CS160 Colorado State University. All Rights Reserved.