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 1RQ
Program Description Answer
In Java all the methods should include all the given options except “a call to another method”.
Hence, the correct answer is option “A”.
Expert Solution & Answer
Explanation of Solution
Method:
A collection of statements which are formed together to perform an operation is called as method.
Declaration of a method:
Method declaration gives the description of what the method should perform; Method declaration holds the modifier, return type, name of the method, the list of parameters and the body of the method.
Syntax for defining a method:
modifier return_type methodName(list of parameters)
{
//body
}
Example:
public int findArea(int x, int y)
{
//body
}
The above statement shows the declaration of the method; here,
- public – modifiers
- int – return type
- findArea – name of the method
- x, y – formal parameters
- int x, int y – list of parameters
- Body is the part of the method that contains the statements and the operations to be performed.
Braces:
- Braces usually enclose the number of statements.
- In a function, the numbers of statements are enclosed within the braces.
- The opening of the function contains the open braces “{”.
- The ending of the function contains the close braces “}”.
Want to see more full solutions like this?
Subscribe now to access step-by-step solutions to millions of textbook problems written by subject matter experts!
Students have asked these similar questions
MUST BE IN JAVA
Following the example of the Circle class in Section 9.2, design a class named Rectangle to represent a rectangle. The class contains: - Two double data fields named width and height that specify the width and height of the rectangle. The default values are 1 for both width and height. - A no-arg constructor that creates a default rectangle. - A constructor that creates a rectangle with the specified width and height. - A method named getArea() that returns the area of this rectangle. - A method named getPerimeter() that returns the perimeter. Draw the UML diagram for the class and then implement the class. Write a test program that creates two Rectangle objects—one with width 4 and height 40 and the other with width 3.5 and height 35.9. Display the width, height, area, and perimeter of each rectangle in this order.Sample RunThe area of a rectangle with width 4.0 and height 40.0 is 160.0The perimeter of a rectangle is 88.0The area of a rectangle with width 3.5 and…
In Java
Given the following CircleDriver.java file. Provide an accompanying Circle.javafile. Specifically, your Circle class should contain:• One instance variable – radius• A method named setRadius that assigns the passed-in radius value to the radiusinstance variable.• A method named initialize that prompts the user for a radius value and thenassigns the entered value to the radius instance variable.• A method named printCircleData that uses the circle’s radius to calculate thecircle’s diameter, circumference, and area. Use the Java API constant Math.PIfor the value of π. Print the circle’s radius, diameter, circumference, and area. Thereare many ways to implement printCircleData. In the interest of gainingexperience with local variables, declare and use local variables for storing thecircle’s diameter, circumference, and area.
The Driver:/***************************************************** CircleDriver.java** This is the driver for the Circle…
Which of the following statements is FALSE about classes in Java?
a
Every program is a class.
b
All methods are classes.
c
All helping software consists of classes.
d
All programmer-defined types are classes.
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
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- I am struggling on this one. This is the question - Write an application that computes and displays the day on which you become(or became) 10,000 days old. For example, if you we're born on January 1st, 2000, the output would be I will be 10000 days old on 2027-05-19. This is the starting code - import java.time.*; public class TenThousandDaysOld { public static void main(String[] args) { // Write code here } }arrow_forwardjava Create a method called next3() that will take an int argument and print the three numbers that come after the given number. The next3() method is already called in the main method. Print in the following format: $number1 $number2 $number3 The three next numbers are printed on the same line with spaces between them This is a void method with an int parameterarrow_forwardWrite/Create a Java objects and class program that creates a car object, and displays the year and name with one method “speed” And will display the following output: Year: 2021 Model: Toyota Speed: 200km/harrow_forward
- Hello, i need help with this question There are 12 inches in a foot and 3 feet in a yard. Create a class named InchConversion. Its main() method accepts a value in inches from a user at the keyboard, and in turn passes the entered value to two methods. One converts the value from inches to feet, and the other converts the same value from inches to yards. Each method displays the results with appropriate explanation. Save the application as InchConversion.java.arrow_forwardCreate a new Java program called MyInfo. Create one or more method(s) that pass the following information as parameters and prints your info when method(s) called. Use appropriate data types and identifiers. Full nameMiddle InitialAgeMajorGPAarrow_forwardIn Java, all arguments are transferred to a method via value call (call by value)? Choose one of the options:TrueFalsearrow_forward
- For the Java code below, you will demonstrate the ability to use and call multiple methods in your program. Using the code below, create the following methods: 1. A method that converts the temperature from Fahrenheit to Celsius. The method should be passed a parameter - Fahrenheit and should return a result - Celsius. 2. A method to output the results of your temperature conversion. The method should be passed 2 parameters - temperature in Fahrenheit and the temperature in Celsius. Finally, place an edit in your code to ensure that the user only enters a numeric value. Your output should appear as follows: Enter the Fahrenheit temperature you want to convert: 212 This converts to 100 Celsius Do you want to convert another temperature – Y or N? Y Enter the Fahrenheit temperature you want to convert: 100 This converts to 37.8 Celsius Do you want to convert another temperature – Y or N? N The program has ended import java.text.DecimalFormat;import java.util.Scanner; public class…arrow_forwardWRITE A JAVA CODE FOR THE FOLLOWING Develop a set of classes for a college to use in various student service and personnel applications. Classes you need to design include the following: • Person — A Person contains the following fields, all of type String: firstName, lastName, address, zip, phone. The class also includes a method named setData that sets each data field by prompting the user for each value and a display method that displays all of a Person’s information on a single line at the command line on the screen. For example: Joe Smith 111-N-Student-Lane 88888 888-888-8888 • CollegeEmployee — CollegeEmployee descends from Person. A CollegeEmployee also includes a Social Security number (ssn of type String), an annual salary (annualSalary of type double), and a department name (dept of type String), as well as methods that override the setData and display methods to accept and display all CollegeEmployee data in addition to the Person data. The display method should display…arrow_forwardWrite a method named raiseSalary that accepts two integers as an argument and returns its sum multiplied by 15%. Write a tester program to test the method. The class name should be your ID (for example Id S190058401). The programming language I'm using is Java. So, It'll be much appreciated if the solution was in Java Please include a screenshot of the solution and use the Example ID in the question Thanksarrow_forward
- Create a class named Percentages whose main() method holds two double variables, and prompt the user for values. Pass both variables to a method named computePercent() that displays the two values and the value of the first number as a percentage of the second one. For example, if the numbers are 2.0 and 5.0, the method should display a statement similar to: 2.0 is 40 percent of 5.0. Then call the method a second time, passing the values in reverse order. An example of the program is shown below: Enter a double >> 3.7 Enter another double >> 12.3 3.7 is 30.081300813008127 percent of 12.3 12.3 is 332.43243243243245 percent of 3.7 Task 01: Create the Percentages class. Task 02: The computePercent() method displays the percent of the first argument of the second argument. Task 03: The Percentages program accepts 2 double values from the console and displays the percent of first value of the second value and vice versa.arrow_forwardCreate an application in Java that calculates the amount of interest for a loan amount. ConsoleWelcome to the Interest CalculatorEnter loan amount: 520000Enter interest rate: .05375Loan amount: $520,000.00Interest rate: 5.375%Interest: $27,950.00Continue? (y/n): yEnter loan amount: 4944.5Enter interest rate: .01Loan amount: $4,944.50Interest rate: 1%Interest: $49.45Continue? (y/n): nSpecificationsThis application should use the BigDecimal class to make sure that all calculations are accurate. It should round the interest that's calculated to two decimal places, rounding up if the third decimal place is five or greater. The application should format currencies to allow for up to 2 decimal places and percentages to allow for up to 3 decimal places. Assume that the user will enter valid double values for the loan amount and interest rate. The application should continue only if the user enters 'y' or 'Y' to the question to continue.arrow_forwardPlease answer the JAVA question below. Based on the below prices double array, create a method call and method that passed in the prices array and determines which value is the lowest. double[ ] prices = {75, 25, 35, 150, 69.99};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:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTEBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Files & File Systems: Crash Course Computer Science #20; Author: CrashCourse;https://www.youtube.com/watch?v=KN8YgJnShPM;License: Standard YouTube License, CC-BY
UNIX Programming (Part - 10) The File System (Directories and Files Names); Author: ITUTEES;https://www.youtube.com/watch?v=K35faWBhzrw;License: Standard Youtube License