[solved]-Task01 1 N1n 2 2 Integer 20 1 Factorial Ofn Defined Product Defined 1 Factorial N Approxim Q39045716



Task01 1 where is n.1n-2… 2 For any integer 20,1, the factorial ofn, is defined as the product defined to be 1 The factorial of n can be approximated, as a value of type double, by the formula: Write a Java program that calls a static void method instruction that displays the following message: This program computes the approximate value of the factorial using the formula proposed by R. W. Gosper. To use this program, the input should be non-negative. Also use values not greater than 143 The program then prompts for and reads an integer, computes, and finally displays the factorial of the input in the format shown in the sample program run below. The factorial must be computed in a static method factorial that uses the above formula. The method must throw an IllegalArgumentException ifn 0 or if n> 143. Note: • The method factorial must not contain any input or output statements • Your main method must handle both java.util. Input MismatchException and java.lang.IllegalArgumentException. Sample program runs: This program computes the approximate value of the factorial using the formal proposed by R. To use this program, the input should be non-negative. Also use values not greater than 143 Enter the value of no n – 14311 fave Error! Java.util. Input M atchException This program computer the approximate value of the factorial using the formula proposed by R. W. Gosper. To use this program, the input should be non-negative. Also we values not greater than 143 Enter the value of n o 1311 – 1 Error: Java.lang.IllegalArgumentException proposed by R. N. GOSP This program compute the approximate value of the factorial using the forma To use this program, the input should be non-negative. Al use value o greater than 143 Enter the value of n0 The approximate factorial of 3 4313 is 5.99613500 Task 02 Write a complete Java program that prompts for and reads the volume, in cubic cm, and height in cm, of a cone, it then calculates and displays the surface area of the cone in square cm. Page 9 of 11 Note: Your main method must: Use two static methods getRadius and getSurfaceArea. There must be no input or output statements in these two methods. Each of these methods must throw IllegalArgumentException if any of its arguments is invalid. Handle both java.util.Input MismatchException and java.lang.IllegalArgumentException. Vh Sample program runs: Enter the volume [cm3] and height (cm) of a cone: 0 6 .0 EEKOR Bava.lang. Illegal ArgumentException Enter the volume [cm3] and height [em] of a cone: 80.0 h Error: java.util. Input MistachException Enter the volume [cm3] and height (cm) of a cone: 57.6 5.0 Surface area – 97.08 square Task 04 of a 1D-array x of type double. Your program must Write a Java program that prompts for and reads the size finally validate the input by looping and displaying an error message until a valid value is entered. If the size n is valid, the program prompts for and reads a values into the array. It then passes this array to a static method reverseArray that creates and returns an array reference to an array which is the reverse of the array I. The program prints the reversed array on the screen using a static method printArray Note: The method reverseArray must not modify the array whose reference is passed to the method. Sample program run: Enter the array Size: -1 Error: The array size is < 0 Enter the array size: 0 Error: The array size is < 0 Enter the array size: 7 Enter 7 values: 5.0 3.0 8.5 7.2 6.3 9.0 12.4 9.0 The reversed array is: 12.4 6.3 7.2 3.5 5.0 3.0 Task 05 of size 10. It then prompts for and Write a Java program that prompts for and reads values into an integer array reads an integer value v. It finally passes the array x and the value to a static method larger Elements that returns a reference to an array containing the elements of that are larger than v, if any. The main method then prints the larger elements Note: The array whose reference is returned to the main must not be a partial array Sample program runs: Enter 10 integer values: 6.3 7.2 8.5 5.0 3.0 8.5 7.2 6.3 5.0 12.1 9.0 The reversed array is: 12.1 3.0 5.0 Task 05 Write a Java program that prompts for and reads values into an integer array of size 10. It then prompts for and Teads an integer value v. It finally passes the array and the value to a static method larger Elements that returns a reference to an array containing the elements of that are larger than y. if any. The main method then prints the larger clements. Note: The array whose reference is retumed to the main must not be a partial array 8 Sample program runs: Enter 10 integer values: 12 1 3 7 10 4 7 3 9 Enter an integer value! 7 The array elements larger than 7 are: 12 10 Enter 10 integer values: 1 2 3 4 5 6 7 8 9 10 Enter an integer value: 12 There are no array elements larger than 12 Enter 10 integer values 3 6 12 9- 547 298 Enter an integer values 10 The array element larger than 10 11 12 Enter 10 Integer values 16 4 10 5 25 6 11 23 7 12 Enter an integer value 2 The array elements larger than 2 are: 16 10 5 25 6 11 23 7 12 Class 235 Show transcribed image text Task01 1 where is n.1n-2… 2 For any integer 20,1, the factorial ofn, is defined as the product defined to be 1 The factorial of n can be approximated, as a value of type double, by the formula: Write a Java program that calls a static void method instruction that displays the following message: This program computes the approximate value of the factorial using the formula proposed by R. W. Gosper. To use this program, the input should be non-negative. Also use values not greater than 143 The program then prompts for and reads an integer, computes, and finally displays the factorial of the input in the format shown in the sample program run below. The factorial must be computed in a static method factorial that uses the above formula. The method must throw an IllegalArgumentException ifn 0 or if n> 143. Note: • The method factorial must not contain any input or output statements • Your main method must handle both java.util. Input MismatchException and java.lang.IllegalArgumentException. Sample program runs: This program computes the approximate value of the factorial using the formal proposed by R. To use this program, the input should be non-negative. Also use values not greater than 143 Enter the value of no n – 14311 fave Error! Java.util. Input M atchException This program computer the approximate value of the factorial using the formula proposed by R. W. Gosper. To use this program, the input should be non-negative. Also we values not greater than 143 Enter the value of n o 1311 – 1 Error: Java.lang.IllegalArgumentException proposed by R. N. GOSP This program compute the approximate value of the factorial using the forma To use this program, the input should be non-negative. Al use value o greater than 143 Enter the value of n0 The approximate factorial of 3 4313 is 5.99613500
Task 02 Write a complete Java program that prompts for and reads the volume, in cubic cm, and height in cm, of a cone, it then calculates and displays the surface area of the cone in square cm. Page 9 of 11 Note: Your main method must: Use two static methods getRadius and getSurfaceArea. There must be no input or output statements in these two methods. Each of these methods must throw IllegalArgumentException if any of its arguments is invalid. Handle both java.util.Input MismatchException and java.lang.IllegalArgumentException. Vh Sample program runs: Enter the volume [cm3] and height (cm) of a cone: 0 6 .0 EEKOR Bava.lang. Illegal ArgumentException Enter the volume [cm3] and height [em] of a cone: 80.0 h Error: java.util. Input MistachException Enter the volume [cm3] and height (cm) of a cone: 57.6 5.0 Surface area – 97.08 square
Task 04 of a 1D-array x of type double. Your program must Write a Java program that prompts for and reads the size finally validate the input by looping and displaying an error message until a valid value is entered. If the size n is valid, the program prompts for and reads a values into the array. It then passes this array to a static method reverseArray that creates and returns an array reference to an array which is the reverse of the array I. The program prints the reversed array on the screen using a static method printArray Note: The method reverseArray must not modify the array whose reference is passed to the method. Sample program run: Enter the array Size: -1 Error: The array size is
Expert Answer
Answer to Task01 1 where is n.1n-2… 2 For any integer 20,1, the factorial ofn, is defined as the product defined to be 1 The fac… . . .
OR

