Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a515285

Browse files
committed
making use of math class
1 parent 94e4366 commit a515285

File tree

10 files changed

+39
-6
lines changed

10 files changed

+39
-6
lines changed

src/binod/CheckPrime2.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package binod;
2+
import java.util.Scanner;
3+
4+
public class CheckPrime2 {
5+
public static void main(String[] args) {
6+
Scanner sc = new Scanner(System.in);
7+
System.out.println("Enter a number");
8+
int n = sc.nextInt();
9+
boolean flag = true;
10+
if (n == 2) {
11+
System.out.println("prime");
12+
} else {
13+
for (int i = 2; i <= Math.sqrt(n); i++) {
14+
if (n % i == 0) {
15+
flag = false;
16+
}
17+
}
18+
if (flag) {
19+
System.out.println(" prime");
20+
} else {
21+
System.out.println("not prime");
22+
}
23+
}
24+
}
25+
}

src/binod/ContinueDemo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public static void main(String[] args) {
1818
do {
1919
System.out.println("Enter any number");
2020
int n = sc.nextInt();
21-
if (n == 10) {
21+
if (n % 10==0) {
2222
continue;
2323
}
2424
System.out.println(n);

src/Animal.java renamed to src/oop/Animal.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
package oop;
12
public class Animal {
23
String name;
34
float weight;

src/BinaryTreeYT.java renamed to src/oop/BinaryTreeYT.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
package oop;
12
import java.util.LinkedList;
23
import java.util.Queue;
34
public class BinaryTreeYT {

src/Bird.java renamed to src/oop/Bird.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
package oop;
12
public class Bird {
23
String colour;
34
String family;

src/Furniture.java renamed to src/oop/Furniture.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
package oop;
12
public class Furniture {
23
String name;
34
int breadth;
@@ -9,6 +10,6 @@ public class Furniture {
910

1011
}
1112
//why we make constructor: to make the object.
12-
//syntax of object Wall s1= new House();
13-
//public class House{}
14-
// this is constructor House(){}
13+
//syntax of object Wall s1= new oop.House();
14+
//public class oop.House{}
15+
// this is constructor oop.House(){}

src/House.java renamed to src/oop/House.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
package oop;
12
public class House {
23
//this is data declaration while creating class
34
String name;
@@ -63,7 +64,7 @@ void HooveringHouse(){
6364
this.toilets = toilets;
6465
}
6566
//copy constructor
66-
//h1 is the data type of House that's why it expect the data type house as we have created h1 in main folder
67+
//h1 is the data type of oop.House that's why it expect the data type house as we have created h1 in main folder
6768
House(House h1){
6869
this.name=h1.name;
6970
this.toilets=h1.toilets;

src/Machine.java renamed to src/oop/Machine.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
package oop;
12
public class Machine {
23
//data declaration
34
String name;

src/Main.java renamed to src/oop/Main.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
package oop;
12
class Shape {
23
String colour;
34
double area;
@@ -61,7 +62,7 @@ public static void main(String[] args) {
6162
System.out.println(f1.breadth);
6263

6364
System.out.println("This is h1 house");
64-
House h1 = new House("Aakritiko House", 4, 2);
65+
House h1 = new House("Aakritiko oop.House", 4, 2);
6566
System.out.println(h1.name);
6667
System.out.println(h1.bedrooms);
6768
System.out.println(h1.toilets);

src/Vehicle.java renamed to src/oop/Vehicle.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
package oop;
12
public class Vehicle {
23
String name;
34
int price;

0 commit comments

Comments
 (0)