MIT-Curricular/OOP/Java/Lab/Week5/Square.java

18 lines
409 B
Java
Raw Normal View History

2024-09-02 00:11:30 +05:30
import java.util.Scanner;
public class Square {
static double square(double a) {
return a * a;
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter the value you want to square: ");
double a = sc.nextDouble();
sc.close();
System.out.println("The square of " + a + " is: " + square(a));
}
}