Big Java Late Objects
2nd Edition
ISBN: 9781119330455
Author: Horstmann
Publisher: WILEY
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 5.3, Problem 10SC
What does this
public static double mystery(int x, int y)
{
double z = x + y;
z = z / 2.0;
return z;
}
public static void main(String[] args)
{
int a = 5;
int b = 7;
System.out.println(mystery(a, b));
}
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Write a program to draw a chessboard, as shown in Figure 5.6b.
Write the JAVA methods for the following.
Rotate a Line
Rotate a Rectangle
Rotate a Triangle
Rotate a Circle
Rotate a Polygon
Show the output of the following programs. (Hint: Draw a table and list the variables in the columns to trace these programs.) (java language)(a)public class Test {public static void main(String[] args) {for (int i = 1; i < 5; i++) {int j = 0;while (j < i) {System.out.print(j + " ");j++;}}}}
(b)public class Test {public static void main(String[] args) {int i = 0;while (i < 5) {for (int j = i; j > 1; j--)System.out.print(j + " ");System.out.println("****");i++;}}}
(c)public class Test {public static void main(String[] args) {int i = 5;while (i >= 1) {int num = 1;for (int j = 1; j <= i; j++) {System.out.print(num + "xxx");num *= 2;}
System.out.println();i--;}}}
(d)public class Test {public static void main(String[] args) {int i = 1;do {int num = 1;for (int j = 1; j <= i; j++) {System.out.print(num + "G");num += 2;}
System.out.println();i++;} while (i <= 5);}}
Chapter 5 Solutions
Big Java Late Objects
Ch. 5.1 - Consider the method call Math.pow(3, 2). What are...Ch. 5.1 - What is the return value of the method call...Ch. 5.1 - The Math.ceil method in the Java standard library...Ch. 5.1 - It is possible to determine the answer to Self...Ch. 5.2 - What is the value of cubeVolume(3)?Ch. 5.2 - Prob. 6SCCh. 5.2 - Provide an alternate implementation of the body of...Ch. 5.2 - Declare a method squareArea that computes the area...Ch. 5.2 - Consider this method: public static int...Ch. 5.3 - What does this program print? Use a diagram like...
Ch. 5.3 - Prob. 11SCCh. 5.3 - What does this program print? Use a diagram like...Ch. 5.4 - Prob. 13SCCh. 5.4 - What does this method do? public static boolean...Ch. 5.4 - Implement the mystery method of Self Check 14 with...Ch. 5.5 - How do you generate the following printout, using...Ch. 5.5 - Prob. 17SCCh. 5.5 - Prob. 18SCCh. 5.5 - Prob. 19SCCh. 5.5 - The boxString method contains the code for...Ch. 5.6 - Consider the following statements: int...Ch. 5.6 - Consider this method that prints a page number on...Ch. 5.6 - Consider the following method that computes...Ch. 5.6 - The comment explains what the following loop does....Ch. 5.6 - In Self Check 24, you were asked to implement a...Ch. 5.7 - Explain how you can improve the intName method so...Ch. 5.7 - Prob. 27SCCh. 5.7 - What happens when you call intName(0)? How can you...Ch. 5.7 - Trace the method call intName(72), as described in...Ch. 5.7 - Prob. 30SCCh. 5.8 - Which lines are in the scope of the variable i...Ch. 5.8 - Which lines are in the scope of the parameter...Ch. 5.8 - The program declares two local variables with the...Ch. 5.8 - There is a scope error in the mystery method. How...Ch. 5.8 - Prob. 35SCCh. 5.9 - Consider this slight modification of the...Ch. 5.9 - Consider this recursive method: public static int...Ch. 5.9 - Consider this recursive method: public static int...Ch. 5.9 - Prob. 39SCCh. 5.9 - The intName method in Section 5.7 accepted...Ch. 5 - In which sequence are the lines of the Cubes.java...Ch. 5 - Write method headers for methods with the...Ch. 5 - Give examples of the following methods from the...Ch. 5 - Prob. 4RECh. 5 - Consider these methods: public static double...Ch. 5 - Prob. 6RECh. 5 - Design a method that prints a floating-point...Ch. 5 - Write pseudocode for a method that translates a...Ch. 5 - Describe the scope error in the following program...Ch. 5 - For each of the variables in the following...Ch. 5 - Prob. 11RECh. 5 - Perform a walkthrough of the intName method with...Ch. 5 - Consider the following method: public static int...Ch. 5 - Consider the following method that is intended to...Ch. 5 - Suppose an ancient civilization had constructed...Ch. 5 - Give pseudocode for a recursive method for...Ch. 5 - Give pseudocode for a recursive method that sorts...Ch. 5 - Write the following methods and provide a program...Ch. 5 - Write the following methods and provide a program...Ch. 5 - Prob. 4PECh. 5 - Prob. 5PECh. 5 - Prob. 6PECh. 5 - Prob. 7PECh. 5 - Prob. 8PECh. 5 - Write methods public static double...Ch. 5 - Write a recursive method public static String...Ch. 5 - Write a recursive method public static boolean...Ch. 5 - Use recursion to implement a method public static...Ch. 5 - Use recursion to determine the number of digits in...Ch. 5 - Write a method that computes the balance of a bank...Ch. 5 - Write a method that tests whether a file name...Ch. 5 - It is a well-known phenomenon that most people are...Ch. 5 - Prob. 3PPCh. 5 - Use recursion to compute an, where n is a positive...Ch. 5 - Leap years. Write a method public static boolean...Ch. 5 - In Exercise P3.13 you were asked to write a...Ch. 5 - Prob. 10PPCh. 5 - Write a program that reads two strings containing...Ch. 5 - Prob. 12PPCh. 5 - Write a program that reads words and arranges them...Ch. 5 - Prob. 14PPCh. 5 - Write a program that reads two fractions, adds...Ch. 5 - Write a program that prints the decimal expansion...Ch. 5 - Write a program that reads a decimal expansion...Ch. 5 - Write two methods public static void...Ch. 5 - Write a program that reads in the width and height...Ch. 5 - Repeat Exercise P5.19 with hexagonal circle...Ch. 5 - Postal bar codes. For faster sorting of letters,...Ch. 5 - Write a program that reads in a bar code (with :...Ch. 5 - Write a program that converts a Roman number such...Ch. 5 - A non-governmental organization needs a program to...Ch. 5 - Having a secure password is a very important...Ch. 5 - Prob. 30PPCh. 5 - Prob. 31PPCh. 5 - Electric wire, like that in the photo, is a...Ch. 5 - The drag force on a car is given by FD=12v2ACD...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Golf Scores The Springfork Amateur Golf Club has a tournament every weekend. The club president has asked you t...
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
The following statement attempts to create a Rectangle object. Find the error. Rectangle box = new Rectangle;
Starting Out with Java: From Control Structures through Data Structures (3rd Edition)
Show the output of the following program: public class Test { public static void main(String[] args) { char x =...
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
In the following exercises, write a program to carry out the task. The program should use variables for each of...
Introduction To Programming Using Visual Basic (11th Edition)
Write a function called i to insert one character string into another string. The arguments to the function sho...
Programming in C
Modify the temperature conversion program to print a heading above the table.
C Programming Language
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
- PROGRAM SIMULATION. Understand the given JAVA program and write the output. b. public class ChangeIt { public void doIt( int[] z ) { z[0] = 0; } } public class TestIt { public static void main ( String[] args ) { int[] myArray = {1, 2, 3, 4, 5} ; ChangeIt.doIt(myArray ); for (int j=0; j<myArray.length; j++ ) System.out.print( myArray[j] + " " ) ; } }arrow_forwardWrite a Program to check Name of Week according to number using Switch Case1:Monday 2: Tuesday …….7:Sunday (( please do it in java and i also add a picture example of this)arrow_forwardWrite the JAVA methods for the following.1) Rotate a Line2) Rotate a Rectangle3) Rotate a Triangle4) Rotate a Circle5) Rotate a Polygonarrow_forward
- In Java trace the table for a while loop public class Main { public static void main(String[] args) { // Question 2 j = 30; x=5; for (int i=1;i<=2;i++) { while (j > 20) { j=j-x*i; ++x; }// end of while }// end of for j x i j<=2 j>20arrow_forwardSolve it quickly please now By using Java programarrow_forwardWrite a Java program to find the calculate the average of 3 subjects for 5 students using do… while loop. Ouput Enter the Student Name:xxxx Sub1=99 Sub2=99 Sub=99 Sum=sum of 3 subjects Average= sum/3arrow_forward
- Write a program that simulates a simple calculator. It reads two integers and a character. If the character is a ‘+’, the sum is printed; if it is a ‘-’, the difference is printed; if it is a ‘*’, the product is printed; if it is a ‘/’, the quotient is printed; and if it is a ‘%’, the remainder is printed.(refrance:C++) Note:please give me solution handwrittenarrow_forwardComputer Science Write a Java program that reads a line and a line segment and then determines whether they intersect or not. When they overlap completely, consider that as intersecting. Use variables ((lp1x, lp1y), (lp2x, lp2y)) to represent a line and ((sp1x, sp1y), (sp2x, sp2y)) to represent a line segmentarrow_forwardIn Java trace the table for the do while loop public class Main { public static void main(String[] args) { int x,j,y; /// Question 1 j = 30; x=5; do { j=j-x-2; --x; }while (j > 20); j x j>20arrow_forward
- public class Turn{public static void main(String[] args){// Different initial values will be used for testingint x = 1; int y = 1; // Turn the arrow by 90 degrees System.out.print("x:", y + 90);System.out.println(x);System.out.print("y: ", x - 1 );System.out.println(y); // Turn the arrow again System.out.print("x:", y - 1);System.out.println(x);System.out.print("y: ",x + 90);System.out.println(y);}}arrow_forwardCreate a simple calculator using Java Swingarrow_forwardWrite a program that reads a mile in a double valuefrom the console, converts it to kilometers, and displays the result. The formulafor the conversion is as follows:1 mile = 1.6 kilometersHere is a sample run:learn from examplesEnter miles: 96 [ENTER]96 miles is 153.6 kilometersarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Java random numbers; Author: Bro code;https://www.youtube.com/watch?v=VMZLPl16P5c;License: Standard YouTube License, CC-BY