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
Concept explainers
Question
Write a java
method accepts two integer parameters (num1 and num2) and calculates the sum of these two
squares (num12 + num22). The main method includes the method call, passing the following values
(2, 3) to the Squares() method and the output displaying the sum of the squares in the command line
window.
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 3 steps with 1 images
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
- Write a method call DisplaySineTable(), that prompts the user for a starting value and an step size. The method will calculate and display a table (10 rows) of sine values based on the user input. Use the built-in method Math.Sin() to obtain the sine of an angle. e.g. if the starting value is 0.5 and the step size is 0.03 the method will display the following table:0.50 0.47940.53 0.50550.56 0.53110.77 0.6961arrow_forwardJava Programarrow_forwardNo written by hand solution Java Please Define stubs for the methods called by the below main(). Each stub should print "FIXME: Finish methodName()" followed by a newline, and should return -1. Example output: FIXME: Finish getUserNum() FIXME: Finish getUserNum() FIXME: Finish computeAvg() Avg: -1 import java.util.Scanner; public class MthdStubsStatistics { //solution here public static void main(String [] args) { int userNum1; int userNum2; int avgResult; userNum1 = getUserNum(); userNum2 = getUserNum(); avgResult = computeAvg(userNum1, userNum2); System.out.println("Avg: " + avgResult); } }arrow_forward
- in java Write a program called AveMethod (main method) that contains a method calledthreeAve (method name) that computes the average of three numbers. NO CREDIT if amethod is not used.a) The main method will do the following:• asks the user for 3 number (double type).• calls the threeAve method• print the average of the three numbersb) The threeAve method will do the following:• receives 3 numbers (parameters)• calculate the average of the three numbers• returns the averagearrow_forwardjava program give comments for the code please. Write a program that calls these two methods as described below A void method that ask user to input an integer to be a parameter and prints following pattern. For example, the user entered 5 as input, the pattern will be: 5 4 3 2 1 5 4 3 2 5 4 3 5 4 5 b. A void method takes Sting as a parameter. Then print out all the vowels in the string. Example given below: Please enter a String. Christopher Vowel in the String:ioearrow_forwardJava language Write a method to find the number of hours, minutes, and seconds and then display it as shown below. The method receives the total number of seconds as parameters. Output is Hour[totalSeconds=3750, nb_Hours=1, nb_Minutes=2, nb_Seconds=30]arrow_forward
- in java Assign courseStudent's name with Smith, age with 20, and ID with 9999. Use the printAll() member method and a separate println() statement to output courseStudent's data. Sample output from the given program:Name: Smith, Age: 20, ID: 9999 Learn how our autograder works 528040.3489652.qx3zqy7 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 idNum=studentId; } publicintgetID() { returnidNum; } } // ===== end ===== // ===== Code from file StudentDerivationFromPerson.java ===== public class StudentDerivationFromPerson { publicstaticvoidmain(String[] args) { StudentcourseStudent=newStudent(); /* Your solution goes here */ } } // ===== end =====arrow_forwardWrite a program called LoopMethod (main method) that contains a method called printNums (method name) that prints the numbers from a specified start to end value. a) The main method will do the following: • asks the user for start and end number (int type). • calls the printNums methodb) The printNums method will do the following: • receives start and end number (parameters)• prints from the start to the end number using a loop Sample Run: Input start number: 3Input end number: 93 4 5 6 7 8 9Input start number: 9Input end number: 219 10 11 12 13 14 15 16 17 18 19 20 21arrow_forwardChapter 5. PC #13. isPrime Method A prime number is a number that is evenly divisible only by itself and 1. For example, the number 5 is prime because it can be evenly divided only by 1 and 5. The number 6, however, is not prime because it can be divided evenly by 1, 2, 3, and 6. Write a method named isPrime, which takes an integer as an argument and returns true if the argument is a prime number, or false otherwise. Demonstrate the method in a complete program. The program should ask the user to enter a number for primality test or a negative number to exit. Tip: Recall that the % operator divides one number by another, and returns the remainder of the division. In an expression such as num1 % num2, the % operator will return 0 if num1 is evenly divisible by num2. Test Case 1 Please enter a number to check for primality or -1 to exit:\n2ENTER2 is a prime number.\nPlease enter a number to check for primality or -1 to exit:\n3ENTER3 is a prime number.\nPlease enter a…arrow_forward
- a Java program that defines and uses 3 overloaded methods (the Java file nameshould be “MethodOverload.java” and all the 3 methods should have the same methodname max). The 3 method headers are given below with their definitions:• int max(int n1, int n2, int n3):o to return the maximum of the passed 3 integer arguments.• double max(double d1, double d2, double d3):o to return the maximum of the passed 3 double arguments with use ofMath.max() method—that is, do not use if or if-else statement incomparing the numbers to find the smaller/smallest numbers.• int max(int n):In the main method of the application, a loop with switch-statement inside is required fortesting the different method calls and you need to generate random numbers for the inputsas the arguments for the methods (except for die-rolling case where an input is enteredfrom the keyboard.). Specifically:• int max(int n1, int n2, int n3): the 3 random integers should be from the sequence2, 5, 8, 11, 14.• double max(double d1,…arrow_forwardQuestion Two Write a java program that prints student's name, grades and GPA. You must do the following requirements: 1. Create three methods: a. First method to accept and print your first, last name, and GPA. 2. Call the three methods you created above in your main method. b. Second method Markt and print your grades Marks of three courses (type: int) 3. Create a method without parameters that would return only your GPA. The method should be named with your last name followed by GPA (e.g., AlwalledGPA()). Note: c. Third method to overload the second method (types: double). The method must print your grades. 4. Declare a double variable that holds the returned value of the last method you created. 5. Print the value of your GPA variable. Help ● The class name of your Java program must be your first name. • Your answer should have the code as text as well as the screenshot of the program output (using your own name) as a part of your answer. Otherwise, zero marks will be awarded.…arrow_forwardWrite a public static method name sumAll that takes in 2 arguments int a, int b, and returns the sum of all values between those two numbers inclusive. Remember a can be less than b, b might be less than a, or they may be equal. They can also be positive or negative. Example: sumAll(2,5); int returned by method: 14 Example: sumAll(5,2); int returned by method: 14 Example: sumAll(3,3); int returned by method: 6 Example: sumAll(3,5); int returned by method: 12 Example: sumAll(-4,3); int returned by method: -4 Example: sumAll(-4,2); int returned by method: -7 Example: sumAll(-5,-2); int returned by method: -14 Example: sumAll(-5,2); int returned by method: -12 Example: sumAll(-2,5); int returned by method: 12 Example: sumAll(-5,-3); int returned by method: -12 Example: sumAll(3,-5); int returned by method: -9 Example: sumAll(-3,5); int returned by method: 9arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
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