Upload files to "OOP/Java/Lab/Week10"
This commit is contained in:
parent
22f306573d
commit
0b8cfc509f
5 changed files with 162 additions and 0 deletions
23
OOP/Java/Lab/Week10/root.java
Normal file
23
OOP/Java/Lab/Week10/root.java
Normal 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);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue