BUILDING JAVA PROGRAMS-TEXT
5th Edition
ISBN: 2810023481209
Author: REGES
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Expert Solution & Answer
Chapter 4.1, Problem 1SCP
Explanation of Solution
Improving the performance:
a)
- z is odd:
- The logical test version of the above given English statement is: z%2==1
- The logic for the even number is z%2==0 which means the given logic is for the odd numbers.
b)
- z is not greater than y’s square root:
- The logical test version of the above given English statement is: z <= Math.sqrt(y).
- If z is not greater than y’ square root, then the possibilities are that it may be lesser than or equal to y; square root.
c)
- y is positive:
- The logical test version of the above given English statement is: y > 0
- The numbers greater than zero are considered to be positive numbers.
d)
- Either x or y is even, and the other is odd:
- The logical test version of the above given English statement is: x % 2 != y % 2.
- If x%2 results zero then y%2 should result as one, which means both of the results cannot be the same.
e)
- y is a multiple of z:
- The logical test version of the above given English statement is: y % z == 0.
- If y mod z which is y%z results zero, then z is known to be the factor of y.
f)
- z is not zero:
- The logical test version of the above given English statement is: z != 0
- “!=” implies not equal to which means z is not equal to zero...
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionChapter 4 Solutions
BUILDING JAVA PROGRAMS-TEXT
Ch. 4.1 - Prob. 1SCPCh. 4.1 - Prob. 2SCPCh. 4.1 - Prob. 3SCPCh. 4.1 - Prob. 4SCPCh. 4.1 - Prob. 5SCPCh. 4.1 -
Consider the following method:
public static void...Ch. 4.1 - Prob. 7SCPCh. 4.1 - Prob. 8SCPCh. 4.1 - Prob. 9SCPCh. 4.1 - Prob. 10SCP
Ch. 4.1 -
The following code is poorly structured:
int sum...Ch. 4.1 -
The following code is poorly structured:
Scanner...Ch. 4.1 - Prob. 13SCPCh. 4.1 - Prob. 14SCPCh. 4.2 - Prob. 15SCPCh. 4.2 - Prob. 16SCPCh. 4.2 - Prob. 17SCPCh. 4.2 - Prob. 18SCPCh. 4.2 - The following code was intended to print a...Ch. 4.3 - Prob. 20SCPCh. 4.3 - Prob. 21SCPCh. 4.3 - Prob. 22SCPCh. 4.3 - Prob. 23SCPCh. 4.3 - Prob. 24SCPCh. 4.4 - Prob. 25SCPCh. 4.4 - Prob. 26SCPCh. 4.4 - The following method attempts to return the median...Ch. 4.4 - Prob. 28SCPCh. 4.4 - Prob. 29SCPCh. 4 - Prob. 1ECh. 4 - Prob. 2ECh. 4 -
Write a method called season that takes as...Ch. 4 - Prob. 4ECh. 4 - Prob. 5ECh. 4 - Prob. 6ECh. 4 - Prob. 7ECh. 4 - Prob. 8ECh. 4 - Write a method called evenSumMax that accepts a...Ch. 4 - Write a method called printGPA that accepts a...Ch. 4 - Prob. 11ECh. 4 - Prob. 12ECh. 4 - Prob. 13ECh. 4 - Prob. 14ECh. 4 - Prob. 15ECh. 4 - Prob. 16ECh. 4 - Prob. 17ECh. 4 - Prob. 18ECh. 4 - Write a method called quadrant that accepts as...Ch. 4 - Prob. 20ECh. 4 - Prob. 21ECh. 4 - Prob. 22ECh. 4 - Write a program that prompts for a number and...Ch. 4 -
Write a program that prompts for a date (month,...Ch. 4 - Prob. 3PPCh. 4 - Prob. 6PPCh. 4 - Prob. 8PP
Knowledge Booster
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education