# Answer to Question #58700 in Java | JSP | JSF for Lekorius Wallace

Question #58700

Suppose a user wants to calculate the square of a number or the square root of a number, and display the results.

Expert's answer

import java.util.Scanner;

public class Square {

public static void main(String[] args) {

System.out.println("Input your number:");

Scanner scanner = new Scanner(System.in);

int n = scanner.nextInt();

System.out.println("Square of a number: " + (n*n));

System.out.println("Square root of a number: " + Math.sqrt(n));

}

}

public class Square {

public static void main(String[] args) {

System.out.println("Input your number:");

Scanner scanner = new Scanner(System.in);

int n = scanner.nextInt();

System.out.println("Square of a number: " + (n*n));

System.out.println("Square root of a number: " + Math.sqrt(n));

}

}

Need a fast expert's response?

Submit orderand get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

## Comments

## Leave a comment