From 28b91b804adb31ce30d57c584c73e85aa061edde Mon Sep 17 00:00:00 2001 From: Aadit Agrawal Date: Mon, 2 Sep 2024 00:11:30 +0530 Subject: [PATCH] Upload files to "OOP/Java/Lab/Week5" --- OOP/Java/Lab/Week5/Square.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 OOP/Java/Lab/Week5/Square.java diff --git a/OOP/Java/Lab/Week5/Square.java b/OOP/Java/Lab/Week5/Square.java new file mode 100644 index 0000000..a1f9432 --- /dev/null +++ b/OOP/Java/Lab/Week5/Square.java @@ -0,0 +1,17 @@ +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)); + } +}