Question

Complete the program involving a class for a right triangle

Complete the program involving a class for a right triangle

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include<bits/stdc++.h>
using namespace std;
////////////// printTriangle class ///////////
class printTriangle
{

///////// Public access specifier //////////////
public:
void print(int n)
{
cout<<"The right triangle is :\n";
for(int i=1;i<=n;i++){
for(int j=1;j<=i;j++)
cout<<"*";
cout<<endl;
}
}
};

///////////// Main Method ////////////
int main()
{
///////////////// Input number ///////////////
int number;
cout<<"Please Enter Number : ";
cin>>number;
printTriangle ob;
ob.print(number);
return 0;
}

///////////// If you have any doubt please let me know in comment section. Good Luck ////////////////

Add a comment
Know the answer?
Add Answer to:
Complete the program involving a class for a right triangle
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • (The Triangle class) Design a class named Triangle that extends the GeometricObject class. The Triangle class...

    (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...

  • in Java This program will output a right triangle based on user specified height triangleHeight and...

    in Java This program will output a right triangle based on user specified height triangleHeight and symbol triangleChar. (1) The given program outputs a fixed-height triangle using a character. Modify the given program to output a right triangle that instead uses the user-specified trianglechar character. (1 pt) (2) Modify the program to use a nested loop to output a right triangle of height triangleHeight. The first line will have one user-specified character, such as % or* Each subsequent line will...

  • Java programming 1. (Triangle class) Design a new Triangle class that extends the abstract GeometricObject class....

    Java programming 1. (Triangle class) Design a new Triangle class that extends the abstract GeometricObject class. Draw the UML diagram for the classes Triangle and GeometricObject and then implement the Triangle class. Write a test program that prompts the user to enter three sides of the triangle, a color, and a Boolean value to indicate whether the triangle is filled. The program should create a Triangle object with these sides and set the color and filled properties using the input....

  • (In C++) The program will output a right triangle based on user specified height triangleHeight and...

    (In C++) The program will output a right triangle based on user specified height triangleHeight and symbol triangleChar. Modify the program to use a nested loop to output a right triangle of height triangleHeight. The 1st line will have one user-specified character, such as %or * Each subsequent line will have 1 additional user-specified character until the number in the triangle"s base reaches triangleHeight. Output a space after each user-specified character, including after the line"s last user-specified character. Example output...

  • 1 @ GONE 7 Acea involving rectangies and triangles A right triangle is removed from a...

    1 @ GONE 7 Acea involving rectangies and triangles A right triangle is removed from a rectangle to ơeate the shaded region shown below. Find the area of the shaded region. Be sure to indude the ernt int I necessary, refer to the ist at geometrs fomulos-

  • 1 // This program will input the value of two sides of a right triangle and...

    1 // This program will input the value of two sides of a right triangle and then 2 // determine the size of the hypotenuse. 3 4 // PLACE YOUR NAME HERE 5 6 #include <iostream> 7 #include <cmath> Il needed for math functions like sqrt() 8 using namespace std; 9 10 int main() 11 { 12 float a, b; // the smaller two sides of the triangle 13 float hyp; // the hypotenuse calculated by the program 14 15...

  • In C programming language: This program will output a right triangle based on user specified height...

    In C programming language: This program will output a right triangle based on user specified height triangleHeight and symbol triangleChar. (1) The given program outputs a fixed-height triangle using a * character. Modify the given program to output a right triangle that instead uses the user-specified triangleChar character. (1 pt) (2) Modify the program to use a nested loop to output a right triangle of height triangleHeight. The first line will have one user-specified character, such as % or *....

  • In a right triangle, the square of the length of one side is equal to the...

    In a right triangle, the square of the length of one side is equal to the sum of the squares of the lengths of the other two sides. Write a program that prompts the user to enter the lengths of three sides of a triangle and then outputs a message indicating whether the triangle is a right triangle. If the triangle is a right triangle, output It is a right-angled triangle If the triangle is not a right triangle, output...

  • Introduction to Java:Design a class named Triangle that extends GeometricObject.

    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...

  • white a program that determines if 3 numbers that are entered, by the user, are sides of a right triangle.

     project 5 functions calling functions white a program that determines if 3 numbers that are entered, by the user, are sides of a right triangle. remember any combination of numbers can be entered, 3 4 5, 5 4 3, 4 3 5... are all the same right triangle. you must have a function that does exponentiation, one that does input one that does output. and one that does the comparisons the main will be this code main:    jal allwork    li $v0,10    syscall function allwork will...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT