Question: Type the following java code shown in this handout 85% Charts SmartArt Review ent Elements Tables Paragraph Styles Ab AaBbCcDdEe Normal Text Bo CA Lab7-Introduetion
85% Charts SmartArt Review ent Elements Tables Paragraph Styles Ab AaBbCcDdEe Normal Text Bo CA Lab7-Introduetion to Methods Lab Objectives: Te develep ability to write void and value returning methods and to call them Istroductien: Metheds are commonly used so beeak a problem down into small manageable pieces. A large task cam be broken dows into smaller taiks methods) that contain the details of how to complete that small task The larger problen is then solved by implemensing the smaller taiks (calling the methods) in the correct onder. This also alilews for efficiencies, since the methed can be called as many times as needed without rewriting the code each time Task 81 voidMethods . Type the code (Geometry java) shown in at the end of this handout. This peogram will compile, bat when you run it, it doesm't appear to do anyshing ex.cept wait. That is because it a waiting for sser iepat, but the user doesa't have the meta to choose frem yet. We will seed to create this 2. Above the main method, but in the Geomery class, create a static method called printMenu that has no parameter list and daes sot return a value. B win simply print out instructions the user with a menu of eptons for the user to choose from The =ctu should appear to the user as: this is geometry calculator Choose what you wouldike to caleulate Find the area of circle Find the area ofa rectagle Find the area of a triangle Pind the elreunference of a circle rind the perineter ofa rectangle Find the perinoter of triangle Enter the nanber ot your choice: 3. Add a lise is the main method that calls the printMenu method as indicated by the conments 4 Compile, debug, and run You should be able to choose any option, but you will always get 0 Sce the answer. We will fix this in the next tasi Task #2 Value-Returning Methods 1. Write a static method called circle Area that takes in the redius of the cirele and returns the azea using the formula A 2. Write a static methed called rectangleAres that takes in the length and width of xr the rectangle and returss the area uning the formula A- J. writ" satic method called triangleArea that takesthe base and height of tha triangle retaras the area using the formula A-hak. 4. Write a stane medod called circleCireumference that takes in the radius of the cincle and returns the circum ference using the fernula C-2xr. s. Write a static method called rectangle Ferimeter har takes in the length and Ge width of the roctangle and returns the perimeter of the reclangle using the formula P-2+2w 6. Writesseatic method called trianglePerimeter that takes in the lengtohs of the three sides of the briangle snd retums the perimeter of the triangle which s calculated by adding up the three sides. Task #3 Calling Methods 1. Add lincs in the main method in the Ceometry class which will eall these methots The comments indicae where te place the method calls 2. Compile, debug, and na. Test ost the pregram wsing your sample data rint Layout View Sec 1 Pages: 1 of3 Words: 971 of 993 12
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
