Given class Triangle (in files Triangle.h and Triangle.cpp), complete main() to read and set the base and height of triangle1 and of triangle2, determine which triangle's area is smaller, and output that triangle's info, making use of Triangle's relevant member functions.
Ex: If the input is:
3.0 4.0 4.0 5.0
where 3.0 is triangle1's base, 4.0 is triangle1's height, 4.0 is triangle2's base, and 5.0 is triangle2's height, the output is:
Triangle with smaller area: Base: 3.00 Height: 4.00 Area: 6.00
Triangle.cpp
#include "Triangle.h"
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
void Triangle::SetBase(double userBase) {
base = userBase;
}
void Triangle::SetHeight(double userHeight) {
height = userHeight;
}
double Triangle::GetArea() const {
return 0.5 * base * height;
}
void Triangle::PrintInfo() const {
cout << fixed << setprecision(2);
cout << "Base: " << base << endl;
cout << "Height: " << height << endl;
cout << "Area: " << GetArea() << endl;
}
main.cpp
#include <iostream>
#include "Triangle.h"
using namespace std;
int main() {
Triangle triangle1;
Triangle triangle2;
// TODO: Read and set base and height for triangle1 (use SetBase() and SetHeight())
// TODO: Read and set base and height for triangle2 (use SetBase() and SetHeight())
cout << "Triangle with smaller area:" << endl;
// TODO: Determine smaller triangle (use GetArea())
// and output smaller triangle's info (use PrintInfo())
return 0;
}
Triangle.h
Trending nowThis is a popular solution!
Step by stepSolved in 4 steps with 1 images
- suppose there is a class Roster. Roster has one variable, roster, which is a list of tuples containing the names of students and their numerical grades- for example, [('Richard',90), ('Belle',67), ('Christine',85), ('Francine',97)]. Roster has a function called calculateAverage that calculates the average of the students in their roster. Write a statement that returns the average of the Roster object englishClass, which has already been defined. using pythonarrow_forward53. Write a class with two instance variables, representing an old password and a new password. Write a recursive method that returns the number of places where the two passwords have different characters. The passwords can have different lengths. Write another, nonrecursive method returning whether the two passwords are sufficiently different. The method takes an int parameter indicating the minimum number of differences that qualify the passwords as being sufficiently different. Your program should include a client class to test your class.arrow_forwardGiven 4 numbers (passed in as parameters) write a function that returns the average of these numbers please write this with a function in java form example function.somthing() and make an html file of the version as well please somthing like this function Numbers() { for (let i = 1; i <= 10; i++) { console.log(i);} } i just need somethig simple like function() var a = (make the user put a random nuber in) var b = (make the user put a random nuber in) var c = (make the user put a random nuber in) var d = (make the user put a random nuber in) return a+b+c+d/4 WITH OUT PYTHON PLZ WITHOUT THIS CODE below import java.util.Scanner; public class AverageClass { public static void main(String[] args) { int a, b, c, d; Scanner sc = new Scanner(System.in); System.out.print("Enter 4 numbers : "); a = sc.nextInt(); b = sc.nextInt(); c = sc.nextInt(); d = sc.nextInt(); System.out.println("Average : " + average(a, b, c, d)); } static float average(int a, int b, int…arrow_forward
- Implement a function alterCase in Python that converts a word to "alterCase". Given a word, using any mix of upper and lower case letters, the function then returns the same word, except that the first letter is upper case, the second is lower case, and then cases of letters alternate throughout the rest of the word. >>> alterCase('apple')'ApPlE'arrow_forwardUsing Python, answer the followingarrow_forwardWritten in Python with docstring please if applicable Thank youarrow_forward
- Your task is to create a function that simulates a vending machine. Given an amount of money (in cents ¢ to make it simpler) and a product Number, the vending machine should output the correct product name and give back the correct amount of change. The coins used for the change are the following: [500, 200, 100, 50, 20, 10] The return value is an object with 2 properties: • product: the product name that the user selected. change: an array of coins (can be empty, must be sorted in descending order). Examples vendingMachine (products, 200, 7) vending Machine (products, 500, 0) → "Enter a valid product number" vendingMachine (products, 90, 1) "Not enough money for this product" → {product: "Crackers", change: [50, 20, 10arrow_forwardin c++ codearrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education