1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
iragen [17]
1 year ago
11

Given class triangle (in files triangle.h and triangle.cpp), complete main() to read and set the base and height of triangle1 an

d of triangle2, determine which triangle's area is larger, 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 larger area:
base: 4.00
height: 5.00
area: 10.00
given (in main.cpp):
#include
#include "triangle.h"
using namespace std;
int main(int argc, const char* argv[]) {
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())
// todo: determine larger triangle (use getarea())
cout << "triangle with larger area:" << endl;
// todo: output larger triangle's info (use printinfo())
return 0;
}
Computers and Technology
1 answer:
kow [346]1 year ago
3 0

The C++ program that would complete the main () and set the base and height of triangle1 and of triangle2 is:

main.cpp

#include <iostream>

#include "Triangle.h"

using namespace std;

int main()

{

   Triangle Tri1;  

Triangle Tri2;

   double base1, height1, base2, height2;

   cout << "Enter a base for your Triangle1: ";

   cin >> base1;

   cout << "Enter a height for your Triangle1: ";

   cin >> height1;

   cout << endl;

   cout << "Enter a base for your Triangle2: ";

   cin >> base2;

   cout << "Enter a height for your Triangle2: ";

   cin >> height2;

   cout << endl;

   

   cout << "################################" << endl;

   

   cout << "Triangle with larger area:" << endl;

   if ((0.5)*base1*height1 > (0.5)*base2*height2){

      Tri1.setValues(base1, height1);

      Tri1.getValues();

      cout << "Area: " << Tri1.getArea() << endl << endl;

}

else{

 Tri2.setValues(base2, height2);

 Tri2.getValues();

    cout << "Area: " << Tri2.getArea() << endl;

}

   

   return 0;

}

Read more about C++ programs here:

brainly.com/question/20339175

#SPJ1

You might be interested in
I need a C++ program to ask the user to put in different numbers until zero is pressed then the program counts the numbers that
frozen [14]

Answer:

#include <iostream>

using namespace std;

int main()

{

int input = 0;

int count = 0;

int sum = 0;

int sumNegative = 0;

while (true) {

 cout << "Enter a number: ";

 cin >> input;

 if (input == 0) break;

 count++;

 sum += input;

 if (input < 0) {

  sumNegative += input;

 }

}

cout << "Count of the numbers: " << count << endl;

cout << "Sum of all the numbers: " << sum << endl;

cout << "Sum of the negative numbers: " << sumNegative << endl;

}

Explanation:

Your requirements regarding the sum and the negative numbers was a bit vague so I just did something you can probably adjust easily to your liking.

7 0
2 years ago
Sarah maintains a blog about her soap-making business, and she has hired someone to create a database for this business. She mak
ivann1987 [24]
The database planner would most likely create a table that contains customer contact information since these would be the individuals who placed an order for Sarah's products after visiting her blog. 
4 0
3 years ago
3.6 Code Practice on Edhesive
Alchen [17]

I've included my code in the picture below. Best of luck.

6 0
2 years ago
Molly, a technician, has been tasked with researching an emulator for the software developers to test cross-platform application
Tresset [83]

Answer:

Option (C) and (D) are the correct answers.

Explanation:

Because Hypervisor is an application or software that provides you a platform by which you can operate another application or software which is not supported to the current operating system just like, you can operate the mobile applications on your system with the help of Hypervisor software. In other words, it is an emulator that provides you the platform to operate different applications on your system.

8 0
3 years ago
Write a program that reads a list of words. Then, the program outputs those words and their frequencies. The input begins with a
tekilochka [14]

Answer:

The following are the program to the given question:

import java.util.*;//import package for user input

public class Make  //define class Make

{

public static void main(String[] ask)  //define a main method

{

  Scanner obx = new Scanner(System.in);   //declare the Scanner class object

  int size=obx.nextInt(); //get the size of the array from the user

  int a[]=new int[size]; //declare an integer array with given size

  String word[]=new String[size]; //declare a string array with given size

  for(int i=0;i<size;i++) //set the for loop  

  word[i]=obx.next(); //get string input from the user

  for(int i=0;i<size;i++)   //iterates with the array, increase the count

  {

    for(int j=0;j<size;j++)   //defining a loop to check value

    {

      if(word[i].equals(word[j]))  //use if to check that elements of words          

      a[i]++;//increamenting array size

    }

  }

 System.out.print("\n");  //use print for break line  

  for(int i=0;i<size;i++)//set for loop to print the following result

    System.out.println(word[i]+" "+a[i]);//print value

 }

}

Output:

Please find the attachment file.

Explanation:

  • First, establish the predefined package required and instead define the main class and define the main method within the class and method.
  • Declare the scanner class object and receive an object size in the 'size' variable thru the array.
  • Next create two arrays, the integer type "a" with both the input size given and the string type "word" with the input size supplied.
  • Define the loop for which string array elements are acquired and set two to again for loop, which increases with loop iteration the integer data type array by one.
  • Lastly, set the loop for which this result is printed.

5 0
2 years ago
Other questions:
  • Derek has an interest in designing video games. What requirements should he fulfill to be a game designer?
    13·1 answer
  • If variable x has value 2 and y has value 2, what is the value of the following Jack expression?
    9·1 answer
  • Your mom is trying to save room on her hard drive and wants to uninstall some of her applications. She asks you how to do this.
    9·2 answers
  • Which of the following is an example of a formal business standard
    14·2 answers
  • A two-dimensional array can be viewed as ___________ and _____________.
    10·1 answer
  • You install a teanviewer on your work station at home so that you can access it when on the road. How can you be assured that un
    12·1 answer
  • What are the classifications of computer
    9·1 answer
  • Is anyone a robIox moderator?
    13·2 answers
  • Explain why this scenario could put an organization in jeopardy of losing some of its workforce.
    12·1 answer
  • Why is it important to continiously conduct penetration testing for a strong security system?.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!