EBK JAVA PROGRAMMING
9th Edition
ISBN: 9781337671385
Author: FARRELL
Publisher: CENGAGE LEARNING - CONSIGNMENT
expand_more
expand_more
format_list_bulleted
Expert Solution & Answer
Chapter 3, Problem 10RQ
Program Description Answer
The legally coded return statement for the method with the declaration “public static int getVal(double sum)” is “return 77”.
Hence, the correct answer is option “B”.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
a) Write a boolean method called sumDivisibleByFive that returns true if the sum of the digits of its integer
parameter is divisible by 5 and false otherwise. For example, if the parameter passed to the method is 73
then the sum of its digits is 10 (7+3) The method should return true since 10 is divisible by 5.
b) Write a main method that calls the method sumDivisibleByFive for the values between 10 and 100
inclusive 10 per line. This should output the following numbers:
14 19 23 28 32 3741 46 50 55
64 69 73 78 82 87 91 96
a) Write a boolean method called sumDivisibleByFive that returns true if the sum of the digits of its integer
parameter is divisible by 5 and false otherwise. For example, if the parameter passed to the method is 73
then the sum of its digits is 10 (7+3). The method should return true since 10 is divisible by 5.
b) Write a main method that calls the method sumDivisibleByFive for the values between 10 and 100
inclusive 10 per line. This should output the following numbers:
14 19 23 28 32 37 41 46 50 55
Using java
64 69 73 78 82 87 91 96
a) Write a boolean method called productDivisibleByThree that returns true if the product of the digits of
its integer parameter is divisible by 3 and false otherwise. For example, if the value passed to the method
is 23 then the product of its digits is 6 (2*3). The method should retum true since 6 is divisible by 3.
b) Write a main method that calls the method productDivisibleByThree for the values between 10 and 50
inclusive 10 per line. This should output the following numbers:
10 13 16 19 20 23 26 29 30 31
Using java
32 33 34 35 36 37 38 39 40 43
46 49 50
Chapter 3 Solutions
EBK JAVA PROGRAMMING
Ch. 3 - Prob. 1RQCh. 3 - Prob. 2RQCh. 3 - Prob. 3RQCh. 3 - Prob. 4RQCh. 3 - Prob. 5RQCh. 3 - Prob. 6RQCh. 3 - Prob. 7RQCh. 3 - Prob. 8RQCh. 3 - Prob. 9RQCh. 3 - Prob. 10RQ
Ch. 3 - Prob. 11RQCh. 3 - Prob. 12RQCh. 3 - Prob. 13RQCh. 3 - Prob. 14RQCh. 3 - Prob. 15RQCh. 3 - Prob. 16RQCh. 3 - Prob. 17RQCh. 3 - Prob. 18RQCh. 3 - Prob. 19RQCh. 3 - Prob. 20RQCh. 3 - Prob. 1PECh. 3 - Prob. 2PECh. 3 - Prob. 3PECh. 3 - Prob. 4PECh. 3 - Prob. 5PECh. 3 - Prob. 6PECh. 3 - Prob. 7PECh. 3 - Prob. 8PECh. 3 - Prob. 9PECh. 3 - Prob. 10PECh. 3 - Prob. 11PECh. 3 - Prob. 12PECh. 3 - Prob. 13PECh. 3 - Prob. 1GZCh. 3 - Prob. 2GZCh. 3 - Prob. 1CP
Knowledge Booster
Similar questions
- Write a method that returns the lcm (least common multiple) of an unspecified number of integers. The method header is specified as follows: public static int lcm(int... numbers) Write a test program that prompts the user to enter five numbers, invokes the method to find the lcm of these numbers, and displays the lcm.arrow_forward7arrow_forwardPart-1: Write a program that includes in its class the following methods: 1. A method named print Chars that takes two characters and an integer with the following header: public static void printChars (char ch1, char ch2, int numberPerLine) This method prints the characters between ch1 and ch2 with the specified numbers per line. Characters are separated by exactly one space. 2. A method named getLetters that takes two characters and an integer and returns a String with the following header: public static String getLetters (char ch1, char ch2, int numberPerLine) This method returns a String that includes the uppercase and lowercase English letters between chl and ch2 with the specified numbers per line. Letters are separated by exactly one space. 3. In your main method, use the methods you implemented to: a. Print all characters between 1 and Z, ten characters per line. b. Print all English letters between S and j, five characters per line.arrow_forward
- Part-1: Write a program that includes in its class the following methods: 1. A method named printChars that takes two characters and an integer with the following header: public static void printChars (char chl, char ch2, int numberPerLine) This method prints the characters between ch1 and ch2 with the specified numbers per line. Characters are separated by exactly one space. 2. A method named getLetters that takes two characters and an integer and returns a String with the following header: public static String getLetters (char ch1, char ch2, int numberPerLine) This method returns a String that includes the uppercase and lowercase English letters between ch1 and ch2 with the specified numbers per line. Letters are separated by exactly one space. 3. In your main method, use the methods you implemented to: a. Print all characters between 1 and Z, ten characters per line. b. Print all English letters between S and j, five characters per line.arrow_forwardClass: DoubleMethod Write a method using the header below public static double readDouble(String prompt) that displays the prompt string, followed by a space, then reads a floating-point number from the user, and returns it. Here is a typical usage: salary = readDouble("Please enter your salary:");percentageRaise = readDouble("What percentage raise would you like?");Write a test program to test the method.arrow_forwardQuestion 2 Write a method int countMultiplesofFive (int x, int y) that returns the number of multiples of 5 bounded between x and y inclusive. In the main, ask the user to enter two positive numbers (both must be positive, if users enter a negative value, they keep reentering values until both numbers are positive). Use the method countMultiplesofFive to find and print how many multiples of 5 exists between the two entered numbers inclusive. Sample run 1: First random: 11 Second random: 80 There are 14 umber that are multiple of five between 11 and 80 Sample run 2: First random: 75 Second random: 33 There are 9 number that are multiple of five between 33 and 75arrow_forward
- 2) Two integers are said to be relatively prime if their greatest common divisor (GCD) is one. For example 12 and 13 are relatively prime, but 12 and 14 are not. a. Write a method called relativelyPrime that accepts two integer parameters A and B. The method should output if A, and B are relatively prime or nat. Use the following method header: public static void relativelyPrime(int A, int B) b. Write a test program (main) to test the method by asking the user to input two positive integers X and Y. Then the program will call the method relativelyPrime to output if X and Y are relatively prime or not. Sample Run 1: Enter Two positive integers X and Y: 12 13 12 and 13 are relatively prime Sample Run 2: Enter Two positive integers X and Y: 12 14 12 and 14 are not relatively primearrow_forwardA).In order to call another method in the same class, it must be declared before (above) the method that calls it. B). Changing the order that methods are declared in a source file has no effect on the run-time behavior of the program. C). How many parameters does the main method have? D). In the following example, how many arguments are passed to the printf method? E). What is the result type of Math.round(1.2345)? F). How do you write π 5 in Java? Write the expression itself, not the value 306.02. Don't write any semicolons or extra spaces. G). What value does the hello method return to main? H). What does the following program output to the user? I). If you're truly doing incremental development, all the code you write will be part of the final solution. J). Which type of comment does Javadoc process? K). Look up the Java documentation for the Scanner class. How many of its methods begin with the word next? Be sure to count the next() method.arrow_forward1. What is method Overloading? Which of the below code contains correct overloading code? Why would the other won't work? Code 1 Code 2 double myMultiply (int x){ int myMultiply (int x){ return 10 * x; return 10 * x; } } double myMultiply (double x){ double myMultiply (int x){ return 20 * x; return 20 * x; }arrow_forward
- The scope of a is the body of its method. O a. default O b. parameter O c. class O d. staticarrow_forwardNeed help with 11 and 12 if possible. Java Code.arrow_forwardAssume you are working in a Python program and you have been given the following lines of Python code studentFirstName = “Pat” studentLastName = “Brown” studentFullName = concatNames(studentFirstName, studentLastName) Assume there is currently no method called concatNames in the file you are working on. In the space below, write the Python code to create a method called concatNames that will take in two values called fName and lName. The method should concatenate the names and return the full name of the student as one String called totalName.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,EBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage