Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
7th Edition
ISBN: 9780134802213
Author: Tony Gaddis
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Expert Solution & Answer
Chapter 5.2, Problem 5.8CP
Program Description Answer
The “public static void showValues (int num1, int num2)” method header is declared with return type of the method, method name and the parameter list.
Hence, the correct answer is option “D”.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Question 2 has bigger options otherwise according to your policy they are 3 questions at a time.
1.) The signature of a method consists of ____________. a. method name b. parameter list c. return type d. None of the above 2.) You should fill in the blank in the following code with ______________. public class Test { public static void main(String[] args) { System.out.print("The grade is "); printGrade(78.5); System.out.print("The grade is "); printGrade(59.5); } public static void __________ (double score) { if (score >= 90.0) { System.out.println('A'); } else if (score >= 80.0) { System.out.println('B'); } else if (score >= 70.0) { System.out.println('C'); } else if (score >= 60.0) { System.out.println('D'); } else { System.out.println('F'); } } } a. int b. printGrade c. printMe
d. double e. void 3.) Assume double[][] x = new double[10][5], what are x.length and x[2].length? a. 4 and 4 b. 10 and 5 c. 5 and 10 d. 5 and 5
Write a method with the following header to display threenumbers in decreasing order:public static void displaySortedNumbers(double num1, double num2, double num3)Write a test program that prompts the user to enter three numbers and invokes themethod to display them in decreasing order.
What value is returned from the following method?
public static double methodA()
{
double a = 8.5 + 9.5;
return a;
}
Chapter 5 Solutions
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
Ch. 5.1 - What is the difference between a void method and a...Ch. 5.1 - Prob. 5.2CPCh. 5.1 - Prob. 5.3CPCh. 5.1 - What message will the following program display if...Ch. 5.1 - Prob. 5.5CPCh. 5.2 - What is the difference between an argument and a...Ch. 5.2 - Prob. 5.7CPCh. 5.2 - Prob. 5.8CPCh. 5.2 - Prob. 5.9CPCh. 5.2 - What will the following program display? public...
Ch. 5.4 - Prob. 5.11CPCh. 5.4 - Prob. 5.12CPCh. 5.4 - Prob. 5.13CPCh. 5.4 - Prob. 5.14CPCh. 5 - This type of method does not return a value. a....Ch. 5 - Prob. 2MCCh. 5 - Prob. 3MCCh. 5 - Prob. 4MCCh. 5 - A value that is passed into a method when it is...Ch. 5 - Prob. 6MCCh. 5 - Prob. 7MCCh. 5 - Prob. 8MCCh. 5 - Prob. 9MCCh. 5 - True or False: You terminate a method header with...Ch. 5 - Prob. 11TFCh. 5 - Prob. 12TFCh. 5 - Prob. 13TFCh. 5 - Prob. 14TFCh. 5 - Prob. 15TFCh. 5 - Prob. 16TFCh. 5 - Prob. 17TFCh. 5 - True or False: No two methods in the same program...Ch. 5 - True or False: It is possible for one method to...Ch. 5 - True or False: You must have a return statement in...Ch. 5 - Prob. 1FTECh. 5 - Look at the following method header: public static...Ch. 5 - Prob. 3FTECh. 5 - Prob. 4FTECh. 5 - Prob. 1AWCh. 5 - Here is the code for the displayValue method,...Ch. 5 - Prob. 3AWCh. 5 - What will the following program display? public...Ch. 5 - A program contains the following method...Ch. 5 - Prob. 6AWCh. 5 - Prob. 7AWCh. 5 - Write a method named square that accepts an...Ch. 5 - Write a method named getName that prompts the user...Ch. 5 - Write a method named quartersToDol1ars. The method...Ch. 5 - Prob. 1SACh. 5 - Prob. 2SACh. 5 - What is the difference between an argument and a...Ch. 5 - Where do you declare a parameter variable?Ch. 5 - Prob. 5SACh. 5 - Prob. 6SACh. 5 - Prob. 1PCCh. 5 - Retail Price Calculator Write a program that asks...Ch. 5 - Rectangle AreaComplete the Program If you have...Ch. 5 - Paint Job Estimator A painting company has...Ch. 5 - Prob. 5PCCh. 5 - Celsius Temperature Table The formula for...Ch. 5 - Test Average and Grade Write a program that asks...Ch. 5 - Conversion Program Write a program that asks the...Ch. 5 - Distance TraveLed Modification The distance a...Ch. 5 - Stock Profit The profit from the sale of a stock...Ch. 5 - Multiple Stock Sales Use the method that you wrote...Ch. 5 - Kinetic Energy In physics, an object that is in...Ch. 5 - isPrime Method A prime number is a number that is...Ch. 5 - Prime Number List Use the isPrime method that you...Ch. 5 - Even/Odd Counter You can use the following logic...Ch. 5 - Present Value Suppose you want to deposit a...Ch. 5 - Rock, Paper, Scissors Game Write a program that...Ch. 5 - ESP Game Write a program that tests your ESP...
Knowledge Booster
Similar questions
- Write a method called DisplayHorizontalStars(int numberOfStars). This method will output the number of stars horizontally specified by its argument. Call the DisplayHorizontalStars() method three times from your program Main() method, supplying 0, 5 and 10 respectively for the number of stars. Write a method similar to the one above that displays a vertical line of stars.Call this method three times with arguments 0, 5 and 10 respectively. Write a method that accepts an argument of type double. The method will calculate and display the volume of a sphere with radius specified by its argument. [ ].Call this method from your main three times, with arguments 1, 2, and 10 respectively. The answers are 4.1888, 33.5103 and 4188.7902 respectively.Use Math.PI for the value of Write a method that takes two arguments: a cost price and a two-letter province code. It will calculate and display the selling price. (If province is Ontario a tax of 13% is added to the price, if the province is…arrow_forwardWhich of the following statements are true about static methods.? Static methods do not need an object in a class to be invoked. Math.sin(x) is an example of a static method. Inside a class, a static method belonging to the class can be invoked by using its name. Outside a class, a static method is invoked by using the name of the class - like Math,pow. All of the above are true statements about static methods.arrow_forwardWrite a method to display a pattern as follows:11 21 2 3...n n−1 ... 3 2 1The method header ispublic static void displayPattern(int n)arrow_forward
- 1). What will be returned from the following method? public static double methodXY() { double a = 6.5 + 8.5; if( a > 12) return a; else return 10; }arrow_forward3. Create a program for Smalltown Regional Airport Flights that accepts either an integer flight number or string airport code from the options in Figure 8-33. Pass the user’s entry to one of two overloaded GetFlightInfo() methods, and then display a returned string with all the flight details. The method version that accepts an integer looks up the airport code, name, and time of flight; the version that accepts a string description looks up the flight number, airport name, and time. The methods return an appropriate message if the flight is not found. Farrell, Joyce. Microsoft Visual C#: An Introduction to Object-Oriented Programming (MindTap Course List) (p. 347). Cengage Learning. Kindle Edition.arrow_forwardWhich of the following would be a valid method call for the following method? public static void showProduct(double num1, int num2){ double product; product = num1 * num2; System.out.println("The product is " + product);} Which of the following would be a valid method call for the following method? public static void showProduct(double num1, int num2){ double product; product = num1 * num2; System.out.println("The product is " + product);} Group of answer choices showProduct("5", "40"); showProduct(3.3, 55); showProduct(10.0, 4.6); showProduct(10, 4.5);arrow_forward
- Modify the program below to create a class that contains a static method; the method takes a string as a parameter and returns a boolean value indicating whether the parameter string has repeated characters in it or not. That is, return true if there is at least one character which appears more than once in the string. The string should be input by the .user import java .util.*; public class Main{public static void main(String args[]){Scanner scn=new Scanner(System.in); // Input the string from userSystem.out.println ( "Enter the String to check for duplicate characters:");String str = scn.next();// Check is variable to store bool value true// It will change to true if there are repeated charactersboolean check=false;for (int a = 0; a < str.length(); a++)for (int b = a + 1; b < str.length(); b++)if (str.charAt(a) == str.charAt(b))check=true;// If check is true then string has repeated characters if (check)System.out.println("The String " + str + " has repeated…arrow_forwardSuppose you have declared a variable as int myAge = 21;. Which of the following is a legal call to a method with the following declaration?private static void AMethod(int num) a. AMethod(myAge); b. AMethod(int myAge); c. AMethod(); d. AMethod(int 55);arrow_forwardThis method simulates the playing of one round of “Rock Paper Scissors”. In this strange version of the game, if both players have the same hand gestures, the return value is 1. If they have different hand gestures, the return value is a 0. If at least one player, provides a string argument that is anything other than rock, paper, or scissors, the return value is -1. The method should not be case-sensitive. For example, rock, ROCK, Rock, and RocK are all valid. The output is in the image I addedarrow_forward
- Write a method that returns a random number from alist of numbers passed in the argument. The method header is specified as follows:public static int getRandom(int... numbers)arrow_forwardWrite 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_forwardProgram62.javaWrite a program that prompts for a full name (first and last) and assigns it to one string. The program then passes the full name to a void method as its sole parameter. The void method should print the first name, on one line, as many times as indicated by the length of the last name. Sample Output (image below) Program64.javaWrite a program that demonstrates method overloading by defining and calling methods that return the area of a triangle, a rectangle, or a square.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,EBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
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
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage