Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
11th Edition
ISBN: 9780134743356
Author: Paul J. Deitel, Harvey Deitel
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Expert Solution & Answer
Chapter 6, Problem 4.1SRE
Explanation of Solution
Method header:
The method header is the signature of the method. The method declaration consists of method header and the body. The parameters are declared in the parameter list which is located inside the parentheses that follow the method name in the method header...
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
c# Now, modify the program so that the major functions appear in the following individual methods:
GetMonth - This method prompts for and returns the month
GetNumMurals - This method prompts for and returns the number of murals scheduled and is called twice -- once for interior murals and once for exterior murals
ComputeRevenue - This method accepts the number of interior and exterior murals scheduled, accepts the month they are scheduled, displays the interior and exterior prices, and then returns the total expected revenue
DataEntry - This method fills an array with customer names and mural codes and is called twice -- once to fill the array of interior murals and once to fill the array of exterior murals
GetSelectedMurals - This method continuously prompts for mural codes and displays jobs of the corresponding type until a sentinel value is entered
using systeml
using static System.Console;
using System.Globalization;
class MarshallsRevenue
{
staticvoidMain()
{
// Your code here…
a) Write a method that calculates the result of the following formula:
x + (x + k)*+ (x + 2k)' + (x +3k)+. + (x+ nk)
The header of the method is as follows
public static double sum(double x, double k, Int n)
b) Write a main method in which you ask the user to enter the value of x, and then call the sum method
to print the result of the above sum with k- 2.5 and n-10.
Sample run 1:
Enter the value ofx:-4,5
The result of the sumis-3866,5
Sample run 2:
Enter the valuc of .2
The reout of theoun a
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 prime
Chapter 6 Solutions
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
Ch. 6 - A method is invoked with a(n)Ch. 6 - Prob. 1.2SRECh. 6 - Prob. 1.3SRECh. 6 - The keywordindicates that a method does not return...Ch. 6 - Prob. 1.5SRECh. 6 - Prob. 1.6SRECh. 6 - Prob. 1.7SRECh. 6 - An object of classproduces truly random numbers.Ch. 6 - Prob. 1.9SRECh. 6 - Prob. 1.10SRE
Ch. 6 - Prob. 1.11SRECh. 6 - Prob. 1.12SRECh. 6 - For the class Craps in Fig. 6.8, state the scope...Ch. 6 - the variable die1.Ch. 6 - the method rollDice.Ch. 6 - Prob. 2.4SRECh. 6 - Prob. 2.5SRECh. 6 - Write an application that tests whether the...Ch. 6 - Prob. 4.1SRECh. 6 - Method smallest, which takes three integers x, y...Ch. 6 - Prob. 4.3SRECh. 6 - Method intToFloat, which takes integer argument...Ch. 6 - Find the error in each of the following program...Ch. 6 - 1 int sum(int x, int y) { 2 int result; 3 result =...Ch. 6 - 1 void f(float a); { 2 float a; 3...Ch. 6 - 1 void product() { 2int, a = 6; 3int b = 5; 4int c...Ch. 6 - Declare method sphereVolume to calculate and...Ch. 6 - What is the value of x after each of the following...Ch. 6 - What is the value of x after each of the following...Ch. 6 - What is the value of x after each of the following...Ch. 6 - What is the value of x after each of the following...Ch. 6 - What is the value of x after each of the following...Ch. 6 - What is the value of x after each of the following...Ch. 6 - What is the value of x after each of the following...Ch. 6 - (Parking Charges) A parking garage charges a 2.00...Ch. 6 - (Rounding Numbers) Math.floor can be used to round...Ch. 6 - To round numbers to specific decimal places, use a...Ch. 6 - Prob. 5.1ECh. 6 - Write statements that assign random integers to...Ch. 6 - Write statements that will display a random number...Ch. 6 - (Exponentiation) Write a method integer Power...Ch. 6 - Define a method hypotenuse that calculates the...Ch. 6 - Prob. 10.1ECh. 6 - Prob. 11.1ECh. 6 - (Displaying a Square of Asterisks) Write a method...Ch. 6 - (Displaying a Square of Any Character) Modify the...Ch. 6 - Prob. 14.1ECh. 6 - (Separating Digits) Write methods that accomplish...Ch. 6 - (Separating Digits) Write methods that accomplish...Ch. 6 - Prob. 15.3ECh. 6 - (Temperature Conversions) Implement the following...Ch. 6 - Method fahrenheit returns the Fahrenheit...Ch. 6 - Prob. 16.3ECh. 6 - (Find the Minimum) Write a method minimum3 that...Ch. 6 - Prob. 18.1ECh. 6 - (Prime Numbers) A positive integer is prime if its...Ch. 6 - Prob. 20.1ECh. 6 - (Greatest Common Divisor) The greatest common...Ch. 6 - Write a method qualityPoints that inputs a...Ch. 6 - Write an application that simulates coin tossing....Ch. 6 - (Guess the Number) Write an application that plays...Ch. 6 - Prob. 25.1ECh. 6 - Prob. 26.1ECh. 6 - (Craps Game Modification) Modify the craps program...Ch. 6 - (Table of Binary, Octal and Hexadecimal Numbers)...Ch. 6 - (Computer-Assisted Instruction) The use of...Ch. 6 - Prob. 2MDCh. 6 - Prob. 3MDCh. 6 - (Computer-Assisted Instruction: Difficulty Levels)...
Knowledge Booster
Similar questions
- Write a program that allows a user to enter the number of days to rent something Calculate the cost of the rental and print out the total due Different items have different costs: auger for $80 per day chainsaw for $47 per day tiller for $60 per day mower for $31 per day Use at least 2 functions/methods in addition to main: Use one method to read the both the number of days and the item to rent. This function will have two parameters (days and item) Use a second method to return the total cost. This function will have two parameters (days and item) and a return value Sample Run #1 (bold, underlined text is what the user types): Days Item? 3 augerTotal due $240 Sample Run #2 (bold, underlined text is what the user types): Days Item? 2 mowerTotal due $62arrow_forwardCan this be done in Java and not C++arrow_forward088..arrow_forward
- 2. Write a C# application that asks the uscr to input the required data to implement the thrce methods below: (Use Method Overloading to write the methods) a Method Area that takes as input, integer values T (length) and "w (width). calculates the area of a rectangle, and displays it [Area = Ixw] b. Method Area that takes as input, double values 'B' (base) and 'h' (height), calculates the arca of a parallelogram, and displays it. [Arca = B x h] c. Method Area that takes as input, a double value "B' (base) and an integer value *h' (height), calculates the area of a triangle, and displays it [Area =Bh] Sample /O Enter the length of the rectang le: Enter the width of the rectangle: 3 Enter the base of the parallelogran: 3.2 Enter the height of the parallelogran: 6.1 Enter the base of the triangle: 4.2 Enter the he ight of the triangle: 18 ******** The area of the rectangle is 24 The area of the parallelogran is 19.52 The area of the triangle is 21 **********arrow_forwardprevious chapters, you continued to modify the MarshallsRevenue program. Now, modify the program so that the major functions appear in the following individual methods: GetMonth - This method prompts for and returns the month GetNumMurals - This method prompts for and returns the number of murals scheduled and is called twice -- once for interior murals and once for exterior murals ComputeRevenue - This method accepts the number of interior and exterior murals scheduled, accepts the month they are scheduled, displays the interior and exterior prices, and then returns the total expected revenue DataEntry - This method fills an array with customer names and mural codes and is called twice -- once to fill the array of interior murals and once to fill the array of exterior murals GetSelectedMurals - This method continuously prompts for mural codes and displays jobs of the corresponding type until a sentinel value is entered. using System; using static System.Console; using…arrow_forwardANSWER MUST BE IN PYTHON3. This is the method header: #!/bin/python3 import math import os import random import re import sys # # Complete the 'linear_interpolate' function below. # # The function is expected to return a float. # The function accepts following parameters: # 1. int n # 2. List[float] x_knots # 3. List[float] y_knots # 4. float x_input # def linear_interpolate(n, x_knots, y_knots, x_input):arrow_forward
- PLEASE NOTE: IT'S A TEXT BOOK EXERCISE. BOOK NAME: Fundamentals of Computer Programming with Programming Basics with C# (English) Problem: Min Method (Return the Smaller Number) Create a method GetMin(int a, int b), which returns the smaller of two numbers. Write a program, which takes as input three numbers and prints the smallest of them. Use the method GetMin(…), which you have already created. Sample Input and Output Input Output Input Output 123 1 -100-101-102 -102 Hints and Guidelines Define a method GetMin(int a, int b) and implement it, after which invoke it from the main program as shown below. In order to find the minimum of three numbers, first, find the minimum of the first two and then the minimum of the result and the third number: var min = GetMin(GetMin(num1, num2), num3); Refences: Title: Programming Basics with C# Authors: Svetlin Nakov & Team ISBN: 978-619-00-0902-3 (9786190009023) Edition: Faber Publishing, Sofia, 2019arrow_forwardin C++ Language can you answer that questionarrow_forwardWhich of the following statements about Python is true? A. Python only supports object oriented programming. B. Python only supports procedural programming. C. Python supports both procedural and object oriented programming. D. Python supports neither object oriented nor procedural programming. What is true about indentation for method definitions in a class? A. None of the statements may be indented. B. The first line of the definition is not indented, but the statements that follow are. C. The first line of the definition is indented one level more than the class statement and the remaining statements of the method definition are indented an additional level D. Indentation does not matter for method definitions. Which of the following statements about Python is true? A. Python supports inheritance. B. Python does not support operator overloading. C. Python does not support garbage collection. D. Python does not support function overloading.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,C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageEBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
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,
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT