Assume that x is a variable that has been declared as a double and been given a value . Show Write an expression to compute the quartic root of x. The quartic root of a number is the square root of its square root. EXAMPLES: For example, the quartic root of 16.0 is 2.0 because: the square root of 16.0 is 4.0 and the square root of 4.0 is 2.0. Another example: the quartic root of 81.0 is 3.0 because the square root of 81.0 is 9.0 and the square root of 9.0 is 3.0. Thus, to find the quartic root of a number you take the square root of the number and then take the square root of that. In this exercise you must find the quartic root of x in a single expression -- you must not write any statements . Also, you may only use the sqrt() static method defined in the Math class -- no other methods . (HINT: you will need to call the Math.sqrt() method twice-- and you will need to pass the return value of one of those calls as argument to the other call. AND REMEMBER: write an expression , not a statement .)
Terms in this set (14)Find the error in the following method definition: // This method has an error! The header should NOT be terminated with a semicolon. Look at the following method header: public static void showValue(int x) The following code has a call to the showValue method. Find the error. int x = 8; showValue(int x); // Error! The int data type should not be listed in the method call. The statement should read: showValue(x); Find the error in the following method definition: // This method has an error! The method should have a return statement that returns a double value. Find the error in the following method definition: // This method has an error! The method's return type should be double instead of int. Examine the following method header, and then write an example call to the method: public static void doSomething(int x) doSomething(25); Here is the code for the displayValue method, shown earlier in this chapter: For each of the following code segments, indicate whether it will successfully compile or cause an error: a.) displayValue(100); a.) This statement will compile successfully. Look at the following method header: public static void myMethod(int a, int b, int c) Now look at the following call to myMethod: myMethod(3, 2, 1); When this call executes, what value will be stored in a? What value will be stored in b? What value will be stored in c? The value 3 will be stored in a, 2 will be stored in b, and 1 will be stored in c. What will the following program display? public class ChangeParam 1 3.4 A program contains the following method definition: public static int cube(int num) Write a statement that passes the value 4 to this method and assigns its return value to a variable named result. result = cube(4); A program contains the following method: public static void display(int arg1, double arg2, char arg3) Write a statement that calls this method and passes the following variables as arguments: char initial = 'T'; display(age, income, initial); Write a method named timesTen. The method should accept a double argument, and return a double value that is ten times the value of the argument. public static double timesTen(double num) Write a method named square that accepts an integer argument and returns the square of that argument. public static int square(int num) Write a method named getName that prompts the user to enter his or her first name, and then returns the user's input. // Assume java,util.Scanner has been imported. Write a method named quartersToDollars. The method should accept an int argument that is a number of quarters, and return the equivalent number of dollars as a double. For example, if you pass 4 as an argument, the method should return 1.0; and if you pass 7 as an argument, the method should return 1.75. public static double quartersToDollars(int quarters) Sets with similar termschapter 5 part150 terms muk chapter 5 part150 terms ESchmidt15 CS2336 Ch. 6 Checkpoints19 terms gsn313 Java Chapter 526 terms burgas Sets found in the same folderCSCE 111 Ch. 8 Review18 terms bpatterson54242 JAVA Ch. 6 Questions19 terms just4lizzy Java Chapter 5 Methods65 terms NightCloudSurfer Ch. 1033 terms Jason_Fults4 Other sets by this creatorGeology/Earth Science Chapter 209 terms chelsi_sherrell4
Relational Final (Chapters 7 + 10), Chapters 11 +…354 terms chelsi_sherrell4 Relational Final (Chapters 13 + 14)109 terms chelsi_sherrell4 Relational Final (Chapters 11 + 12)133 terms chelsi_sherrell4 Verified questionsCOMPUTER SCIENCE True/False: A list must contain at least one item. Verified answer
COMPUTER SCIENCE This string method returns a copy of a string with all the alphabetic letters converted to uppercase. a. uppercase() b. case_upper() c. upper() d. to_upperCase() Verified answer COMPUTER SCIENCE An English Christmas carol, “The Twelve Days of Christmas,” dates from the late 1700s. The twelve verses in the song are cumulative, each verse adding an additional gift given by “my true love.” The twelfth verse says “On the twelfth day of Christmas, my true love gave to me . . .” 12 Drummers Drumming. 11 Pipers Piping. 10 Lords-a-Leaping . . . and so forth down to . . . 3 French Hens. 2 Turtle Doves. Verified answer
COMPUTER SCIENCE Consider a file system that uses inodes to represent files. Disk blocks are 8KB in size, and a pointer to a disk block requires 4 bytes. This file system has 12 direct disk blocks, as well as single, double, and triple indirect disk blocks. What is the maximum size of a file that can be stored in this file system? Verified answer Recommended textbook solutions
Information Technology Project Management: Providing Measurable Organizational Value5th EditionJack T. Marchewka 346 solutions
Introduction to Algorithms3rd EditionCharles E. Leiserson, Clifford Stein, Ronald L. Rivest, Thomas H. Cormen 720 solutions
Fundamentals of Database Systems7th EditionRamez Elmasri, Shamkant B. Navathe 687 solutions
Service Management: Operations, Strategy, and Information Technology7th EditionJames Fitzsimmons, Mona Fitzsimmons 103 solutions Other Quizlet setsWeek One39 terms Newmanto week 4 test61 terms taylneve
Related questionsQUESTION Since the Python list methods are written in compiled C code, using the Python list to write a program will always be faster than a linked list implemented in Python. 3 answers QUESTION SR 20.12 What imbalance is fixed by a leftright rotation? 2 answers QUESTION True or False: The weight of the MST depends on the starting vertex. 2 answers QUESTION T/F: bully algorithm is not an example of Ordered Hashing 15 answers How do you square a number in Java?Squaring a number in Java can be accomplished in two ways. One is by multiplying the number by itself. The other is by using the Math. pow() function, which takes two parameters: the number being modified and the power by which you're raising it.
How do you code a square root in Java?Java sqrt() method with Examples
Math. sqrt() returns the square root of a value of type double passed to it as argument. If the argument is NaN or negative, then the result is NaN. If the argument is positive infinity, then the result is positive infinity.
How do you find a perfect square in Java?Output 2:. Suppose, n is a number that we want to check.. Create a for loop that executes from 1 to n/2.. Calculate x=i*i, for each iteration.. The variable x has the following three conditions: If x=n, the given number is perfect square. If x>n, n is not a perfect square. Continue if the above two conditions are not true.. |