RectangleFu... X 1 2 import java.awt. Rectangle; W N 3 import java.util.Scanner; 4 5 public class...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
RectangleFu... X 1 2 import java.awt. Rectangle; W N 3 import java.util.Scanner; 4 5 public class RectangleFun 6 { 7 8 9 10 HANGGA998HNEN EN BA 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 public static void main(String[] args) { Terminal Scanner kb = new Scanner (System.in); System.out.print("Width: "); int w = kb.nextInt(); System.out.print("Height: "); int h kb. nextInt (); System.out.print("X: "); int x int y = System.out.print("Y: "); kb.nextInt(); kb.nextInt(); // Instantiate a Rectangle object using w, h, x and y. Rectangle r = new Rectangle (x,y,w,h); X System.out.print("Perimiter System.out.print(r.getwidth()); System.out.print(r.getHeight()); System.out.print(r.getX()); System.out.print(r.getY()); = "); } // Calculate and output the perimeter using Rectangle class methods. 29 30 31 public void Setlocation (int x, int y){ 75% (32:1) codio@sierradialog-limbomatch:~/workspace$ | Guide Collapse Unit 2 - Using Objects -> Topics 2.3, 2.4 and 2.5- Methods 2.3.1 RectangleFun Write a program to enable the user to enter the width, height, and the coordinates for the location of a rectangle. This code is provided. Using the input values, construct a new Rectangle object. Calculate and output the perimeter of the rectangle using Rectangle class methods. Change the location of the rectangle to be 4 units to the left and 2 units up, and then print the new location. You must use the Rectangle methods setLocation, getX, and getY with the values 4 and 2 to do this in a calculation. The prompts and the labels for the output should appear exactly like those shown in the sample run shown below. Use method calls for all calculations and output. DO NOT input new values for these required adjustments, rather make the changes in the program using the methods belonging to the object. The signatures for these methods are as follows: public Rectangle(int x, int y,int width, int height) public double getWidth() public double getHeight() public double getX() public double getY() !!! RectangleFu... X 16 .out.print("Y: "); 17 = kb. nextInt (); 18 19 tantiate a Rectangle object using w, h, x and y. 20 gler = new Rectangle (x,y,w,h); 21 22 .out.print("Perimiter 23 .out.print (r.getwidth()); 24 .out.print(r.getHeight()); 25 . out.print(r.getX()); 26 .out.print(r.getY()); 27 28 29 Terminal culate and output the perimeter using Rectangle class methods. 30 31 d Setlocation (int x, int y) { 32 33 34 35 36 37 38 39 40 41 42 43 = nt the new location. _"'); e the rectangle 2 units up and 4 units to the left using a Rectangle class method. 75% (32:1) .out.print("New location is "); X codio@sierradialog-limbomatch:~/workspace$ Guide X Collapse Unit 2 - Using Objects -> Topics 2.3, 2.4 and 2.5-Methods 2.3.1 RectangleFun public double getX() public double getY() public void setLocation (int x, int y) Sample Run: COMPILE AND RUN Width: 5 Height: 2 X: 3 Y: -5 Perimeter = 14.0 New location is (-1.0,-3.0) First Compile and Run to make sure your program works, debug, edit and repeat if necessary, and then finally click Check It! when ready to submit to the autograder. Once it shows all tests passed, click on Mark as Completed to finish. Check It! !!! RectangleFu... X 1 2 import java.awt. Rectangle; W N 3 import java.util.Scanner; 4 5 public class RectangleFun 6 { 7 8 9 10 HANGGA998HNEN EN BA 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 public static void main(String[] args) { Terminal Scanner kb = new Scanner (System.in); System.out.print("Width: "); int w = kb.nextInt(); System.out.print("Height: "); int h kb. nextInt (); System.out.print("X: "); int x int y = System.out.print("Y: "); kb.nextInt(); kb.nextInt(); // Instantiate a Rectangle object using w, h, x and y. Rectangle r = new Rectangle (x,y,w,h); X System.out.print("Perimiter System.out.print(r.getwidth()); System.out.print(r.getHeight()); System.out.print(r.getX()); System.out.print(r.getY()); = "); } // Calculate and output the perimeter using Rectangle class methods. 29 30 31 public void Setlocation (int x, int y){ 75% (32:1) codio@sierradialog-limbomatch:~/workspace$ | Guide Collapse Unit 2 - Using Objects -> Topics 2.3, 2.4 and 2.5- Methods 2.3.1 RectangleFun Write a program to enable the user to enter the width, height, and the coordinates for the location of a rectangle. This code is provided. Using the input values, construct a new Rectangle object. Calculate and output the perimeter of the rectangle using Rectangle class methods. Change the location of the rectangle to be 4 units to the left and 2 units up, and then print the new location. You must use the Rectangle methods setLocation, getX, and getY with the values 4 and 2 to do this in a calculation. The prompts and the labels for the output should appear exactly like those shown in the sample run shown below. Use method calls for all calculations and output. DO NOT input new values for these required adjustments, rather make the changes in the program using the methods belonging to the object. The signatures for these methods are as follows: public Rectangle(int x, int y,int width, int height) public double getWidth() public double getHeight() public double getX() public double getY() !!! RectangleFu... X 16 .out.print("Y: "); 17 = kb. nextInt (); 18 19 tantiate a Rectangle object using w, h, x and y. 20 gler = new Rectangle (x,y,w,h); 21 22 .out.print("Perimiter 23 .out.print (r.getwidth()); 24 .out.print(r.getHeight()); 25 . out.print(r.getX()); 26 .out.print(r.getY()); 27 28 29 Terminal culate and output the perimeter using Rectangle class methods. 30 31 d Setlocation (int x, int y) { 32 33 34 35 36 37 38 39 40 41 42 43 = nt the new location. _"'); e the rectangle 2 units up and 4 units to the left using a Rectangle class method. 75% (32:1) .out.print("New location is "); X codio@sierradialog-limbomatch:~/workspace$ Guide X Collapse Unit 2 - Using Objects -> Topics 2.3, 2.4 and 2.5-Methods 2.3.1 RectangleFun public double getX() public double getY() public void setLocation (int x, int y) Sample Run: COMPILE AND RUN Width: 5 Height: 2 X: 3 Y: -5 Perimeter = 14.0 New location is (-1.0,-3.0) First Compile and Run to make sure your program works, debug, edit and repeat if necessary, and then finally click Check It! when ready to submit to the autograder. Once it shows all tests passed, click on Mark as Completed to finish. Check It! !!!
Expert Answer:
Answer rating: 100% (QA)
import javautilScanner import javaawtRectangle public class RectangleFun public static void mainStri... View the full answer
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
Hazel has $100,000 in savings that she plans to use as a down payment on a house that costs $650,000. She selects an closed, fixed rate mortgage with a 3-year term, a 20 year amortization period and...
-
Welcome to week 5. This week we will be discussing an important topic, teacher evaluations. There has been a big push to count the teacher evaluation as a determining factor toward incentive pay...
-
A manufacturer purchases a part for use at both of its plants-one at Roseville, California, the other at Akron, Ohio. The part is available in limited quantities from two suppliers. Each supplier has...
-
Which description does NOT fit in description of "issues" in the context of international standards? a. An unsettled matter. b. A vital matter. c. A change in the environment. d. A concern or...
-
In a public corporation, should the CEO of the company also be allowed to be the chairman of the board (as allowed for by the current law)? What problems might this give rise to?
-
As a statistics project, a student examined every cigarette butt along the sidewalk and curb along one block near his home. Of 47 identifiable butts, 22 were Marlboro. (a) What sampling method is...
-
Calculate profitability and asset management ratios using sales and receivables data.} - Because sales revenue is such a key component of a company's success, analysts are interested in a large...
-
The Willow River Mining Company mines and ships coal. It has experienced the following demand for coal during the past eight years: Year Coat Sales (tons) 1 ...........4260 2 ...........4510 3...
-
The Foundational 1 5 ( Algo ) [ LO 7 - 1 , LO 7 - 3 , LO 7 - 4 ] [ The following information applies to the questions displayed below. ] Hickory Company manufactures two products - 1 3 , 0 0 0 units...
-
The Toliza Museum of Art In early 2009, Juan Antonio Jimenez has just begun his new position as Executive Director of the Toliza Museum of Art ("Toliza"). Toliza is a beautiful art museum located in...
-
I am stuck on this question can you please help me? Dog Up! Franks is looking at a new sausage system with an installed cost of $540,000. This cost will be depreciated straight-line to zero over the...
-
(b) Prove that for x> 1 we have *
-
A family of Polulu Metal Gear Motors have speed reduction gear trains that range from 1:1 to 400:1 Part 1: Use the following gear train to solve for the overall gear ratio (output speed/input speed)...
-
Enron has an ideal code of conduct that spread over 6 5 pages, but Enron still had one of the biggest accounting scandals. What went wrong? No plagiarism please.
-
Question 6 Worth 8 points Use the equation xz+ylnx = z to find z/x and z/y.
-
Allbright Ltd manufactures wooden furniture. It uses a job costing system that applies factory overhead on the basis of direct labour hours. Budgeted factory overhead for the year 2020 was...
-
This question: 1 point(s) possible Submit tes Write an equation of the line with the given slope, m, and y-intercept (0,b). m = 0, b = -7 The equation is (Simplify your answer. Type your answer in...
-
CdF2 (s) Cd+ (aq) + 2 F- (aq) 1. A saturated solution of CdF2 is prepared. The equilibrium in the solution is represented above. In the solution [Cd+] eq = 0.0585 M and [F-] eq = 0.117 M. a....
-
a. Wilson filed his individual tax return on the original due date, but failed to pay $700 in taxes that were due with the return. If Wilson pays the taxes exactly 2 months late, calculate the amount...
-
Greg died on July 1, 2012, and left Lea, his wife, a $50,000 life insurance policy which she elects to receive at $5,000 per year plus interest for 10 years. In the current year, Lea receives $6,200....
-
Ken (age 31) and Amy (age 28) Booth have brought you the following information regarding their income, expenses, and withholding for the year. They are unsure which of these items must be used to...
-
describe the diffusion of innovations throughout an industry and market?
-
Can an organization have innovation without creativity?
-
interpret the difference between disruptive innovation and sustaining innovation.
The Political Economy Of Regulation The Case Of Insurance 1st Edition - ISBN: 0887067328 - Free Book
Study smarter with the SolutionInn App