Upload files to "OOP/Java/Lab/Week5"
This commit is contained in:
parent
f7d1aa3358
commit
28b91b804a
17
OOP/Java/Lab/Week5/Square.java
Normal file
17
OOP/Java/Lab/Week5/Square.java
Normal file
@ -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));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user