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 Plus MyLab Programming with Pearson eText -- Access Card Package (11th Edition)
Additional Engineering Textbook Solutions
Computer Systems: A Programmer's Perspective (3rd Edition)
Computer Science: An Overview (12th Edition)
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
Database Concepts (7th Edition)
Starting Out With Visual Basic (7th Edition)
- JAVASCRIPT SOLUTION PLEASE You are going to be given a word. Your job is to return the middle character of the word. If the word's length is odd, return the middle character. If the word's length is even, return the middle 2 characters.arrow_forwardWrite an application that reads an integer and determines and prints whether it’s odd or even. [Hint: Use the remainder operator. An even number is a multiple of 2. Any multiple of 2 leaves a remainder of 0 when divided by 2.]arrow_forwardExtreme Fizz BuzzFizz Buzz is a classic Computer Science problem about Selection. For an integer x, print:• “Fizz” if x is only divisible by 3,• “Buzz” if x is only divisible by 5,• “FizzBuzz” if x is divisible by both 3 and 5,• the number x if it is not divisible by both 3 and 5.This problem is the extreme version of Fizz Buzz. You are given a list of K distinct integers A and a list of K characters S. Both lists are numbered from 1 to K. The integer Ai corresponds to the character Si. Denote B as the subset of A. There will be a rule for each possible subset: if an integerx is only divisible by all elements in B, print a string which is the concatenation of the corresponding character of each element in B, sorted by the index in ascending order. However, if B is an empty subset, print the first digit of x instead. Does it look complicated? Do not worry, as it is just a generalization of the regular Fizz Buzz. For example, if A = [3, 5] and S = [F, B], you will get the normal Fizz…arrow_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
- Using the 3 methods above, create an application that calculates the roots of an equation of second degree: ax 2 + bx + c 0 For it exists, the coefficient a must be nonzero. If delta is positive, then there are two distinct roots: -6+ VA -b- VA and 2a 2a If delta is zero, then there is exactly one real root: 2a If delta is negative, there is no real solution.arrow_forwarduse java as programming languagearrow_forwardAssume you are working as a developer in a bank, and you have been asked to develop a programto validate credit card numbers. Assume also that each credit card number consists of 8 digits. Thefollowing method is used to verify that the credit is valid or not: - Starting from the rightmost digit, form the sum of every other digit. For instance, if thecredit card number is 43589795, then you form the sum 5 + 7 + 8 + 3 = 23. - Double each of the digits that were not included in the preceding step. Add all digits of theresulting numbers. Considering for example the above credit card number 43589795,doubling the digits starting from the next-to-last one, yields 18 18 10 8. Adding all digitsin these values yields 1 + 8 + 1 + 8 + 1 + 0 + 8 = 27 - Add the sum of the two preceding steps. If the last digit of the resulting sum is 0, the creditcard number is valid; otherwise, it is invalid. In our case, 23 + 27 = 50, so the number isvalid. Write an Algorithm and Flowchart draw.arrow_forward
- Assume you are working as a developer in a bank, and you have been asked to develop a programto validate credit card numbers. Assume also that each credit card number consists of 8 digits. Thefollowing method is used to verify that the credit is valid or not: - Starting from the rightmost digit, form the sum of every other digit. For instance, if thecredit card number is 43589795, then you form the sum 5 + 7 + 8 + 3 = 23. - Double each of the digits that were not included in the preceding step. Add all digits of theresulting numbers. Considering for example the above credit card number 43589795,doubling the digits starting from the next-to-last one, yields 18 18 10 8. Adding all digitsin these values yields 1 + 8 + 1 + 8 + 1 + 0 + 8 = 27 - Add the sum of the two preceding steps. If the last digit of the resulting sum is 0, the creditcard number is valid; otherwise, it is invalid. In our case, 23 + 27 = 50, so the number isvalid. 7. On Private Sub Frm_Your_Id_Load(sender As…arrow_forwardAssume you are working as a developer in a bank, and you have been asked to develop a programto validate credit card numbers. Assume also that each credit card number consists of 8 digits. Thefollowing method is used to verify that the credit is valid or not: - Starting from the rightmost digit, form the sum of every other digit. For instance, if thecredit card number is 43589795, then you form the sum 5 + 7 + 8 + 3 = 23. - Double each of the digits that were not included in the preceding step. Add all digits of theresulting numbers. Considering for example the above credit card number 43589795,doubling the digits starting from the next-to-last one, yields 18 18 10 8. Adding all digitsin these values yields 1 + 8 + 1 + 8 + 1 + 0 + 8 = 27 - Add the sum of the two preceding steps. If the last digit of the resulting sum is 0, the creditcard number is valid; otherwise, it is invalid. In our case, 23 + 27 = 50, so the number isvalid. Write a C++ program to validate credit card number using…arrow_forwardIn Python A soup company is interested in finding out how much of their soup will go into various sized cans. The user will input the diameter of the can end, and the height of the can. The volume of a cylinder is the well known formula: volume = area of the ends * height of cylinder. The twist is that a can of soup can not be completely filled to the top; only 95% of the volume can be filled with soup; the remaining 5% must remain empty to allow for expansion. NOTE: when computing the area, use pi to at least 5 significant digits (eg, 3.14159) or use the constant math.pi. You should define a function named soup_volume which takes two parameters, the diameter of the can in cm, and the height of the can in cm, in that order. The function should return a float value, which is the volume of soup that the can is able to hold. The function should not round the value, but when printing the value in the main program, format it to show only 2 decimal places. Example run of the program: Enter…arrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr