Upload files to "OOP/Java/Lab/Week10"

This commit is contained in:
Aadit Agrawal 2024-10-14 02:40:51 +05:30
parent 22f306573d
commit 0b8cfc509f
5 changed files with 162 additions and 0 deletions

View file

@ -0,0 +1,23 @@
import java.util.*;
public class root {
public static void main(String[] args) {
Scanner in=new Scanner(System.in);
System.out.println("Enter the number");
double num=in.nextDouble();
try
{
if(num<0)
{
throw new Exception();
}
System.out.print("Sqaure root=");
}
catch(Exception e)
{
System.out.print("Negative number was entered\nsqaure root=i");
num=-num;
}
double root=Math.sqrt(num);
System.out.print(root);
}
}