Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code changes for [Bug]: Project build / compilation fail when we try to run any class in an IDE. #180

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 46 additions & 46 deletions mersenneprime.java → MersennePrimeDemo.java
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
//To find mersenne's prime upto
import java.util.*;
import java.lang.*;
public class mersenneprime {
public static boolean isPrime(long n){
boolean isPrime =true;
for(int j=2;j<n;j++){
if(n%j==0 || n==1 || n==0){
isPrime=false;
break;
}else{
isPrime=true;
}
}
return isPrime;
}
public static void main(String[] args) {
Scanner scr = new Scanner(System.in);
System.out.println("Enter the range:");
long p= scr.nextLong();
List<Long>twoindexlist=new ArrayList<Long>();
long two=2;
for(int k=1;k<100;k++){
two*=2;
twoindexlist.add(two);
if(two>=p){
break;
}
}
for (Long long1 : twoindexlist) {
System.out.println(long1);
}
/*
for(long i=0; i<p;i++){
if(isPrime(i)==true && twoindexlist.contains(i+1)==true){
System.out.println(i);
}
}*/
}
}
//To find mersenne's prime upto

import java.util.*;
import java.lang.*;

public class MersennePrimeDemo {

public static boolean isPrime(long n){
boolean isPrime =true;

for(int j=2;j<n;j++){
if(n%j==0 || n==1 || n==0){
isPrime=false;
break;
}else{
isPrime=true;
}

}
return isPrime;
}
public static void main(String[] args) {
Scanner scr = new Scanner(System.in);
System.out.println("Enter the range:");
long p= scr.nextLong();
List<Long>twoindexlist=new ArrayList<Long>();
long two=2;

for(int k=1;k<100;k++){
two*=2;
twoindexlist.add(two);
if(two>=p){
break;
}
}
for (Long long1 : twoindexlist) {
System.out.println(long1);
}
/*
for(long i=0; i<p;i++){
if(isPrime(i)==true && twoindexlist.contains(i+1)==true){
System.out.println(i);
}
}*/
}
}
1 change: 0 additions & 1 deletion NumberOfDigit.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
this algorithm has a time complexity of O(n)
we can simply calculate it by log(number)+1.
here is the code for it :- */
import java.util.*;

class NumberOfDigit
{
Expand Down
190 changes: 94 additions & 96 deletions Programs/ADTFractionApp.java
Original file line number Diff line number Diff line change
@@ -1,111 +1,109 @@



package Programs;
public class ADTFractionApp {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
ADTFraction f1=new ADTFraction(3,5);
f1.display();
ADTFraction f2=new ADTFraction(7,8);
f2.display();
ADTFraction f1 = new ADTFraction(3, 5);
f1.display();
ADTFraction f2 = new ADTFraction(7, 8);
f2.display();
}

}


class ADTFraction {
private int n; //numerator
private int d; //denomenator
//---------------------------------------------------
public ADTFraction() {//default constructor
this.n=0;
this.d=1;
}
//---------------------------------------------------
public ADTFraction(int a, int b) {//parameter constructor
private int n; //numerator
private int d; //denomenator

if(b!=0){
this.d=b;
this.n=a;
}
else{
this.n=0;
this.d=1;
System.out.println("Denomenator cannot be Zero");
}


}
//---------------------------------------------------
public void set(int a, int b) {//set numerator and denomenator
if(b!=0){
this.d=b;
this.n=a;
}
else{
this.n=0;
this.d=1;
System.out.println("Denomenator cannot be Zero");
}
}



//---------------------------------------------------
public ADTFraction plus(ADTFraction x) {//add two fractions this=3/5 x=7/8
int num, den;
den=this.d * x.d;
num=this.n * x.d + x.n * this.d;
ADTFraction f1 = new ADTFraction(num,den);
return f1;
}


//---------------------------------------------------
public ADTFraction times(int a) {//multiply fraction by a number
int num, den;
den=this.d;
num=this.n * a;

ADTFraction f1 = new ADTFraction(num,den);
return f1;

//return times(new ADTFraction(a,1))

}


//---------------------------------------------------
public ADTFraction times(ADTFraction x) {//multiply two fractions
int num, den;
den=this.d * x.d;
num=this.n * x.n;

ADTFraction f1 = new ADTFraction(num,den);
return f1;
}


//---------------------------------------------------
public ADTFraction reciprocal() {//reciprocal of a fraction
ADTFraction f1=new ADTFraction(this.d,this.n);
return f1;
}


//---------------------------------------------------
public float value() {//numerical value of a fraction
return (float)this.n/this.d;
}


//---------------------------------------------------
public void display() {//display the fraction in the format n/d
System.out.println(this.n + "/" + this.d);
}
//---------------------------------------------------
public ADTFraction() {//default constructor
this.n = 0;
this.d = 1;
}

//---------------------------------------------------
public ADTFraction(int a, int b) {//parameter constructor

if (b != 0) {
this.d = b;
this.n = a;
} else {
this.n = 0;
this.d = 1;
System.out.println("Denomenator cannot be Zero");
}


}

//---------------------------------------------------
public void set(int a, int b) {//set numerator and denomenator
if (b != 0) {
this.d = b;
this.n = a;
} else {
this.n = 0;
this.d = 1;
System.out.println("Denomenator cannot be Zero");
}
}


//---------------------------------------------------
public ADTFraction plus(ADTFraction x) {//add two fractions this=3/5 x=7/8
int num, den;
den = this.d * x.d;
num = this.n * x.d + x.n * this.d;
ADTFraction f1 = new ADTFraction(num, den);
return f1;
}


//---------------------------------------------------
public ADTFraction times(int a) {//multiply fraction by a number
int num, den;
den = this.d;
num = this.n * a;

ADTFraction f1 = new ADTFraction(num, den);
return f1;

//return times(new ADTFraction(a,1))

}


//---------------------------------------------------
public ADTFraction times(ADTFraction x) {//multiply two fractions
int num, den;
den = this.d * x.d;
num = this.n * x.n;

ADTFraction f1 = new ADTFraction(num, den);
return f1;
}


//---------------------------------------------------
public ADTFraction reciprocal() {//reciprocal of a fraction
ADTFraction f1 = new ADTFraction(this.d, this.n);
return f1;
}


//---------------------------------------------------
public float value() {//numerical value of a fraction
return (float) this.n / this.d;
}


//---------------------------------------------------
public void display() {//display the fraction in the format n/d
System.out.println(this.n + "/" + this.d);
}
//---------------------------------------------------

}
8 changes: 7 additions & 1 deletion Programs/abstractClass.java → Programs/AbstractClass.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Program to demonstrate abstract classes in Java -
package abstractClass;
package Programs;
// No function definition can be added
// Objects of abstract class cannot be created,but object references can be created
// Syntax: abstract type method-name(parameter-list);
Expand Down Expand Up @@ -36,6 +36,12 @@ class triangle extends area {
}
}

/**
* BugFix
* Descriptions:
* 1. Renamed class file from abstractClass to AbstractClass
* 2. Added package name
*/
public class AbstractClass {
public static void main(String[] args) {
// TODO Auto-generated method stub
Expand Down
9 changes: 8 additions & 1 deletion Programs/areaRect.java → Programs/AreaRect.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Program to calculate the area of rectangle using return values -
package area;
package Programs;
class Rectangle {
public int l, b;
public void getData(int m, int n) {
Expand All @@ -11,6 +11,13 @@ public int calcArea() {
return area;
}
}

/**
* BugFix
* Descriptions:
* 1. Renamed class file from areaRect to AreaRect
* 2. Added package name
*/
public class AreaRect {
public static void main(String[] args) {
// TODO Auto-generated method stub
Expand Down
12 changes: 10 additions & 2 deletions Programs/arithExceptions.java → Programs/ArithExceptions.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
// Program to show ArithmeticException Error handling -
public class arithExceptions {
package Programs;

// Program to show ArithmeticException Error handling -
/**
* BugFix
* Descriptions:
* 1. Renamed class file and name from arithExceptions to ArithExceptions
* 2. Added package name
*/
public class ArithExceptions {
public static void main(String[] args) {
// try block -
try {
Expand Down
9 changes: 8 additions & 1 deletion Programs/excHandling.java → Programs/ArrayListProg.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
package excHandling;
package Programs;
import java.util.*;
import java.io.*;

/**
* BugFix
* Descriptions:
* 1. Renamed class file and name from excHandling to ArrayListProg
* 2. Added package name
* 3. Optimized imports
*/
public class ArrayListProg {
public static void main(String[] args) throws IOException {
System.out.println("Program for implementing ArrayList: ");
Expand Down
8 changes: 7 additions & 1 deletion Programs/arrayLists.java → Programs/ArrayLists.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
package ArrayLists;
package Programs;
import java.util.*;

/**
* BugFix
* Descriptions:
* 1. Renamed class file from arrayLists to ArrayLists
* 2. Added package name
*/
public class ArrayLists {
public static void main(String[] args) {
ArrayList<String> cars = new ArrayList<String>();
Expand Down
Loading