Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 3366b47

Browse files
Irani-LaptopIrani-Laptop
Irani-Laptop
authored and
Irani-Laptop
committed
first commit
1 parent 57361a8 commit 3366b47

File tree

7 files changed

+115
-0
lines changed

7 files changed

+115
-0
lines changed

P4P5P6/.classpath

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
4+
<attributes>
5+
<attribute name="module" value="true"/>
6+
</attributes>
7+
</classpathentry>
8+
<classpathentry kind="src" path="src"/>
9+
<classpathentry kind="output" path="bin"/>
10+
</classpath>

P4P5P6/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/bin/

P4P5P6/.project

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>P4P5P6</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.eclipse.jdt.core.javanature</nature>
16+
</natures>
17+
</projectDescription>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
eclipse.preferences.version=1
2+
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
4+
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
5+
org.eclipse.jdt.core.compiler.compliance=11
6+
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
7+
org.eclipse.jdt.core.compiler.debug.localVariable=generate
8+
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
9+
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
10+
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
11+
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
12+
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
13+
org.eclipse.jdt.core.compiler.release=enabled
14+
org.eclipse.jdt.core.compiler.source=11

P4P5P6/src/P4.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
import java.util.Scanner;
3+
public class P4 {
4+
5+
public static void main(String[] args)
6+
{
7+
Scanner input=new Scanner (System.in);
8+
9+
System.out.print("Please enter n: ");
10+
int n=input.nextInt();
11+
12+
13+
// System.out.println(Math.abs(n));
14+
15+
//if (n<0)
16+
// n=-n;
17+
//System.out.println(n);
18+
19+
20+
// n*n = n^2 >=0
21+
System.out.println((int) Math.sqrt(n*n));
22+
23+
24+
}
25+
}

P4P5P6/src/P5.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
2+
import java.util.Scanner;
3+
public class P5 {
4+
5+
public static void main(String[] args)
6+
{
7+
Scanner input=new Scanner (System.in);
8+
9+
System.out.print("Please enter n1: ");
10+
int n1=input.nextInt();
11+
12+
System.out.print("Please enter n2: ");
13+
int n2=input.nextInt();
14+
15+
16+
//System.out.println(Math.min(n1,n2));
17+
18+
//min (n1,n2) = (|n1+n2| - |n1-n2|)/2
19+
20+
int min = (Math.abs(n1+n2)-Math.abs(n1-n2))/2;
21+
22+
System.out.println(min);
23+
}
24+
}

P4P5P6/src/P6.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
2+
import java.util.Scanner;
3+
public class P6 {
4+
5+
public static void main(String[] args)
6+
{
7+
Scanner input=new Scanner (System.in);
8+
9+
System.out.print("Please enter n1: ");
10+
int n1=input.nextInt();
11+
12+
System.out.print("Please enter n2: ");
13+
int n2=input.nextInt();
14+
15+
16+
//System.out.println(Math.min(n1,n2));
17+
18+
//max(n1,n2) = (|n1+n2| + |n1-n2|)/2
19+
20+
int max = (Math.abs(n1+n2)+Math.abs(n1-n2))/2;
21+
22+
System.out.println(max);
23+
}
24+
}

0 commit comments

Comments
 (0)