subject

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
Here is class Triangle:

public class Triangle {
private double base;
private double height;

public void setBase(double userBase){
base = userBase;
}
public void setHeight(double userHeight) {
height = userHeight;
}

public double getArea() {
double area = 0.5 * base * height;
return area;
}

public void printInfo() {
System. out. printf("Base: %.2f\n", base);
System. out. printf("Height: %.2f\n", height);
System. out. printf("Area: %.2f\n", getArea());
}
}

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 06:20
Which text function capitalizes the first letter in a string of text? question 10 options: upper capital first proper
Answers: 1
question
Computers and Technology, 23.06.2019 09:30
Given a link with a maximum transmission rate of 32.8 mbps. only two computers, x and y, wish to transmit starting at time t = 0 seconds. computer x sends filex (4 mib) and computer y sends filey (244 kib), both starting at time t = 0. statistical multiplexing is used, with details as follows packet payload size = 1000 bytes packet header size = 24 bytes (overhead) ignore processing and queueing delays assume partial packets (packets consisting of less than 1000 bytes of data) are padded so that they are the same size as full packets. assume continuous alternating-packet transmission. computer x gets the transmission medium first. at what time (t = ? ) would filey finish transmitting? give answer in milliseconds, without units, and round to one decimal places (e.g. for an answer of 0.013777 seconds you would enter "13.8" without the quotes)
Answers: 3
question
Computers and Technology, 23.06.2019 15:00
In the blank libreoffice writer document, to start the process of entering a date field into a letter, click on the insert menu. edit menu. file menu. fields menu.
Answers: 3
question
Computers and Technology, 24.06.2019 07:00
Selective is defined as paying attention to messages that are consistent with one’s attitudes and beliefs and ignoring messages that are inconsistent.
Answers: 1
You know the right answer?
Given class Triangle (in file Triangle. java), complete main() to read and set the base and height o...
Questions
question
Social Studies, 31.05.2021 18:30
question
Geography, 31.05.2021 18:40
question
World Languages, 31.05.2021 18:40
question
World Languages, 31.05.2021 18:40
question
History, 31.05.2021 18:40
question
Mathematics, 31.05.2021 18:40
Questions on the website: 13722361