Concept explainers
Define a method hypotenuse that calculates the hypotenuse of a right triangle when the lengths of the other two sides are given. The method should take two arguments of type double and return the hypotenuse as a double. Incorporate this method into an application that reads values for side1 and side2 and performs the calculation with the hypotenuse method. Use Math methods pow and sqrt to determine the length of the hypotenuse for each of the triangles in Fig. 6.14. [Note: Class Math also provides method hypot to perform this calculation.]
Fig. 6.14
Values for the sides of triangles in Exercise 6.15 .
Want to see the full answer?
Check out a sample textbook solutionChapter 6 Solutions
Java How To Program (Early Objects)
Additional Engineering Textbook Solutions
Database Concepts (8th Edition)
Java: An Introduction to Problem Solving and Programming (8th Edition)
Modern Database Management
Degarmo's Materials And Processes In Manufacturing
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
Web Development and Design Foundations with HTML5 (8th Edition)
- basic java please Write a void method named emptyBox()that accepts two parameters: the first parameter should be the height of a box to be drawn, and the second parameter will be the width. The method should then draw an empty box of the correct size. For example, the call emptyBox(8, 5) should produce the following output: ***** * * * * * * * * * * * * ***** The width of the box is 5. The middle lines have 3 spaces in the middle. The height of the box is 8. The middle columns have 6 spacesarrow_forwardSemin ew. code that finds the sum of two matrices. Use the following method header public static int[][] addMatrix(int[][] a, int[][] b) The rules for adding two matrices are:1. both matrices should have the exact same dimensions (i.e. height and width) – you need to check for this rule in your program.2. both matrices should have elements that have compatible types – you don’t have to add extra code to check this rule in your method as it will only accept int arrays.arrow_forwardWrite a method that generates and outputs a random permutation of numbers between 1 and 5. A sample output of the method is 2, 4, 1, 3, 5.(C# CONSOLE PROGRAMMİNG)arrow_forward
- Pendulum - Python Eulers methodarrow_forwarduse only C# programming Write a method call CubeIt(int x, ref int cube) that takes two arguments and does not return a value. The method will cube the first argument and assign it to the second argument.In your main, call this method twice and print the value of the parameters after each method call. Write a method with the following header: static void CalculateTuitionFee(int numberOfCourses, double costPerCourse, ref double fees). This method will calculate and assign the required fees amount to the third argument. [Fees = number of courses * cost per course + 15.25].From your program Main() method, call the CalculateTuitionFee () method four times supplying different arguments each time and display the value of the third argument after each method call. Write a method that takes four parameter of type int. The method will assign the sum of the first two arguments to the third and the difference of the first two to the fourth. This method should be coded so that the calling…arrow_forwardJAVA programming language eclipse softwarearrow_forward
- In CORAL LANGUAGE please and thank you! Summary: Given integer values for red, green, and blue, subtract the gray from each value. Computers represent color by combining the sub-colors red, green, and blue (rgb). Each sub-color's value can range from 0 to 255. Thus (255, 0, 0) is bright red, (130, 0, 130) is a medium purple, (0, 0, 0) is black, (255, 255, 255) is white, and (40, 40, 40) is a dark gray. (130, 50, 130) is a faded purple, due to the (50, 50, 50) gray part. (In other words, equal amounts of red, green, blue yield gray). Given values for red, green, and blue, remove the gray part. Ex: If the input is: 130 50 130 the output is: 80 0 80 Hint: Find the smallest value, and then subtract it from all three values, thus removing the gray.arrow_forwardThe area of a pentagon can be computed usingthe following formula: Write a method that returns the area of a pentagon using the following header:public static double area(double side)Write a main method that prompts the user to enter the side of a pentagon anddisplays its area. Here is a sample run:Enter the side: 5.5 ↵EnterThe area of the pentagon is 52.04444136781625arrow_forwardWe need to use the java languagearrow_forward
- Object: SquareStates: sideBehaviors: computeArea(), computePerimeter() Object: RightTriangleStates: base, heightBehaviors: computeArea(), computePerimeter() - Find first the hypotenuse which is the 3rd (longest) side using the Pythagorean formula. You may use the sqrt() method defined in Math Java class KINDLY REFER TO THIS LINK BELOW:arrow_forwardjava programarrow_forward1. Write the following method that returns the intersecting point between two lines (p1, p2) and (p3, p4): public static Point2D getIntersecting Point ( Point 2D pl, Point2D p2, Point 2D p3, Point2D p4); The method returns null if the two lines are parallel. Write a test program that prompts the user to enter three points and displays the center point. Here is a sample run. (Hint: for finding the intersecting point between two lines, see Programming Exercise 8.31.) Enter x1, yl, x2, y2, x3, y3, x4, y4: 2 2 5 -1.0 4.0 2.0 -1.0 -2.0 The intersecting point is at (2.88889, 1.1111) Enter x1, yl, x2, y2, x3, y3, x4, y4: 2 2 7 6.0 4.0 2.0 -1.0 -2.0 The two lines are parallelarrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr