In: Computer Science
The programming language is Java. Write the code you would use to fill the variable cubed with the value stored in x to the third power.
Solution:
import java.util.*;
class Main
{
public static void main(String[] args)
{
int x, cubed;
System.out.println("Enter the value of x: ");
Scanner sc = new Scanner(System.in);
x = sc.nextInt();
//fill the variable cubed with the value stored in x to the third power
cubed = x * x * x;
System.out.println("Value of cubed: "+cubed);
}
}
Output:
Please give thumbsup, if you like it. Thanks.