write a program in java to input 3 integers and find the sum of the cube roots of their last digits.
Answers
Below are program to find sum of Cube roots:
Output:
Enter first integer number: 22
Enter second integer number: 2
Enter third integer number: 3
Sum of cube roots=3.9620916700971547
Explanation:
The program to this question as follows:
Program:
import java.util.*; //import package for user input
import java.lang.*; //import package for using math function
class Root //defining class Root
{
public static void main(String as[])//defining main method
{
int a1,b1,c1,cube_a1,cube_b1,cube_c1; //defining integer variable
Scanner ax=new Scanner(System.in); //creating scanner class object
System.out.print("Enter first integer number: "); //message
a1=ax.nextInt(); //input value by user
System.out.print("Enter second integer number: "); //message
b1=ax.nextInt(); //input value by user
System.out.print("Enter third integer number: "); //message
c1=ax.nextInt(); //input value by user
cube_a1=a1%10; //holding quotient value
cube_b1=b1%10; //holding quotient value
cube_c1=c1%10; //holding quotient value
System.out.println("Sum="+(Math.cbrt(cube_a1)+Math.cbrt(cube_b1)+Math.cbrt(cube_c1))); //print value
}
}
Description of the above code as follows:
- In the above code, two packages in import, in which one is used for user input and second is used for using the math function.
- In the next step, the class "Root" is declared, inside the class main method is defined, in this method there six integer variable "a1, b1, c1, cube_a1, cube_b1, and cube_c1".
- The variable "a1, b1, and c1" is used to take input by the used and "cube_a1, cube_b1, and cube_c1" variable is used to take modules values.
- In the next step, the print function is used that uses the math "cbrt" method that calculates the cube root and all the value.
Learn more:
- Find cube root: https://brainly.in/question/5470084
- What is Cube root: https://brainly.in/question/3256816
Answer:
it is wrong answer and I did not under stood any thing thanks for it .