Computers and Technology

Given class Rectangle (in file Rectangle. java), complete main() to read and set the base and height of rectangle1 and of rectangle2, determine which rectangle's area is smaller, and output that rectangle's info, making use of Rectangle's relevant methods. Ex: If the input is:3.0 4.04.0 5.0where 3.0 is rectangle1's base, 4.0 is rectangle1's height, 4.0 is rectangle2's base, and 5.0 is rectangle2's height, the output is:Rectangle with larger area:Base: 4.00Height: 5.00Area: 12.00public class Rectangle {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 = 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());}}import java. util. Scanner;public class RectangleArea {public static void main(String[] args) {Scanner scnr = new Scanner(System. in);Rectangle Rectangle1 = new Rectangle();Rectangle Rectangle2 = new Rectangle();// TODO: Read and set base and height for rectangle1 (use setBase() and setHeight())// TODO: Read and set base and height for rectangle2 (use setBase() and setHeight())// TODO: Determine larger rectangle (use getArea())System. out. println("Rectangle with smaller area:");// TODO: Output larger Rectangle's info (use printInfo())}}

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 00:00, lilyforeman5867
Match each vocabulary word to its definition.1. desktoppicture used to represent acomputer application2. domainnetwork protectionsoftware code that can be viewed,3. iconmodified, and redistributed for freethe background screen on acomputer monitor4. url5. blogan online journalthe part of an internet address that6. firewallrefers to a group of computers on anetworkonline database of web pages7. intranetnetwork for use by an individual8. open address of a web page or9. wikiresource
Answers: 2
image
Computers and Technology, 22.06.2019 15:00, misslux
This is not a factor that you should use to determine the content of your presentation. your audience your goals your purpose your technology
Answers: 1
image
Computers and Technology, 22.06.2019 19:00, dadonelson2109
If your accelerator suddenly gets stuck what should you do
Answers: 2
image
Computers and Technology, 22.06.2019 23:30, lexirandall19
Define a function printfeetinchshort, with int parameters numfeet and numinches, that prints using ' and " shorthand. ex: printfeetinchshort(5, 8) prints: 5' 8"
Answers: 1
Do you know the correct answer?
Given class Rectangle (in file Rectangle. java), complete main() to read and set the base and height...

Questions in other subjects:

Konu
History, 25.06.2021 17:00