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
LiRa [457]
2 years ago
10

Given class Triangle (in file Triangle.java), complete main() to read and set the base and height of triangle1 and of triangle2,

determine which triangle's area is larger, and output that triangle's info, making use of Triangle's relevant methods. 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
Computers and Technology
1 answer:
kodGreya [7K]2 years ago
8 0

Answer:

<em>The Triangle.java file is not provided; However, the program is as follows;</em>

<em>Comments are used for explanatory purpose</em>

<em>Also see attachment for Triangle.java program file</em>

<em />

import java.util.*;

public class triangle

{

public static void main(String [] args)

{

 Scanner input = new Scanner(System.in);

 //Declare variables

 double base1, height1, base2, height2;

 //Prompt user for inputs

 System.out.println("Provide values for the base and height of the two triangles");

 System.out.print("Base of Triangle 1: ");

 base1 = input.nextDouble();

 System.out.print("Height of Triangle 1: ");

 height1 = input.nextDouble();

 System.out.print("Base of Triangle 2: ");

 base2 = input.nextDouble();

 System.out.print("Height of Triangle 2: ");

 height2 = input.nextDouble();

 //Compare and Print Results

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

 {

  System.out.print("Triangle with larger area: Base: "+base1+" Height: "+height1+" Area: "+(0.5 * base1 * height1));

 }

 else

 {

  System.out.print("Triangle with larger area: Base: "+base2+" Height: "+height2+" Area: "+(0.5 * base2 * height2));

 }

}

}

Download java
You might be interested in
A(n) _____ identifies how you feel about an activity or subject. computer calculator interest inventory both b and c
Alexeev081 [22]

Answer:

Interest

Explanation:

3 0
3 years ago
Read 2 more answers
Round Robin Algorithm
Reil [10]

Answer:

Please check the attachment.

Explanation:

avg turnaround time = (38+7+42+33+18)/5= 27.6

avg waiting timee = (33+5+28+23+17)/5= 21.2

And its D, A C in Gantt chart at last and exit time are 33, 38 and 42 mentioned as last three in Gantt chart.

7 0
2 years ago
Which device protects computer systems from voltage fluctuations?
meriva
A fuse protects computer system from voltage fluctuations
6 0
2 years ago
Read 2 more answers
This is Microsoft Word. ONLY RIGHT ANSWERS. 50 points
pishuonlain [190]
She should select the first sentence then press and hold ALT while selecting the second sentence
5 0
2 years ago
1. What are the advantages and disadvantages of the digital darkroom as compared to a regular
ki77a [65]

Answer:

The advantages of a digital darkroom is that it allows the photographer to make minor changes to improve a photograph. The disadvantage is that the more you want your picture to come out better you would need to waste your time or be patient to get the picture and buy a better camera.

4 0
3 years ago
Other questions:
  • An IT technician has manually configured an IP address on a laptop for a new employee. Each time the employee tries to connect t
    8·1 answer
  • What is a nonlinear presentation
    9·2 answers
  • Fill in the blank
    11·1 answer
  • You’re browsing the internet and realize your browser is not responding. Which of the following will allow you to immediately ex
    11·1 answer
  • What will the following segment of code output?
    7·1 answer
  • Two system administrators who work in two different buildings for the same company want to open a communication channel between
    8·1 answer
  • How many bits does it take to store a 3-minute song using an audio encoding method that samples at the rate of 40,000 bits/secon
    12·1 answer
  • How are keyboards applied in the real world
    13·1 answer
  • Evaluate if the following function is a good candidate to be placed in a library. Why or why not?
    10·2 answers
  • 6.16 LAB: Find largest number (EO) Write a method, findMax(), that repeatedly reads in integers until a negative integer is read
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!