A PHP Error was encountered

Severity: 8192

Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated

Filename: libraries/Filtered_db.php

Line Number: 23

Write a Java program that reads a number and display the square, cube, and fourth power
Q:

Write a Java program that reads a number and display the square, cube, and fourth power

0

Write a Java program that reads a number and display the square, cube, and fourth power

Expected Output:
Square: .2f
Cube: .2f
Fourth power: 50625.00

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

import java.util.Scanner;
public class Exercise8 {

    public static void main(String[] args)
    {
        Scanner in = new Scanner(System.in);
        System.out.print("Input the side length value: ");
        double val = in.nextDouble();

        System.out.printf("Square: %12.2f\n", val * val);
        System.out.printf("Cube: %14.2f\n", val * val * val);
        System.out.printf("Fourth power: %6.2f\n", Math.pow(val, 4));
    }
}

Sample Output:

Input the side length value: 15                                                                               
Square: .2f                                                                                                   
Cube: .2f                                                                                                     
Fourth power: 50625.00  

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now