Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question
The following two methods are supposed to compute the absolute value of 1 number and the absolute value of the sum of 2 numbers respectively. Find and fix 2 errors to make these methods work properly.
public static int abs(int n) { ............................
return n <= 0 ? n : -1 * n; ............................
}
public static int abs(int a, int b) {............................
int c = a + b; ............................
return abs(a,b); ............................
}
Expert Solution
arrow_forward
Step 1
Here have to determine about correct the errors of given code snippet.
Step by stepSolved in 2 steps
Knowledge Booster
Similar questions
- Besides main() this program has one method that computes the amount of raise and the new salary for an employee. The current salary and a performance rating (a String: "Excellent", "Good" or "Poor") are input. import java.util.Scanner; public class Salary { public static void main (String[] args) { Declare variables Prompt for and read current salary and rating For an excellent rating compute raise as 0.06 of current salary For a good rating compute raise as 0.04 of current salary For a poor rating compute raise as 0.015 of current salary You can use abc.equals(“xyz”) to verify the rating read For an invalid rating display an appropriate message and display the salary without change; otherwise, compute and print new salary and raise amount main() must display the message } } Note:- Please type and execute this java program and also need an output for this java program as soon as possible.arrow_forwardpublic static int test(int n, int k) { if (k == 0 || k == n) { return 1; } else if (k>n) { return 0; } else { return test(n-1, k-1) + test(n-1, k); } ww For each of the following calls, indicate the output that is produ test(7,5); test(6,4); test(4,5); test(8,3); test(5,5);arrow_forwardProgram to compute interest = p * r * t, where p = $10K, rate = 6%, t = 10 years; these values are to be passed from main() Besides main() the program has two methods: one that computes the interest and on that rounds interest to two decimal places public class DisplayInterest public static void main(String[] args) call a method that will do the computation with values for the above variables; with the exception of year, they are double main() displays computed interest after rounding computation method() rounding method() Note:- Please type and execute this java program and also need an output for this java program.arrow_forward
arrow_back_ios
arrow_forward_ios
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