Skip to content
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
19 changes: 19 additions & 0 deletions Java/Q10.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import java.util.Scanner;

public class Q10 {

public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);

System.out.println("Enter a number!");
int num = scanner.nextInt();

if(num % 2 == 0)
System.out.println("Number is even");
else
System.out.println("Number is odd");

scanner.close();
}

}
29 changes: 29 additions & 0 deletions Java/Q13.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import java.util.Scanner;

public class Q13 {

public static void main(String[] args) {

Scanner scanner = new Scanner(System.in);

int a, b, c;

System.out.print("Enter co-efficient of x^2: ");
a = scanner.nextInt();
System.out.print("Enter co-efficient of x: ");
b = scanner.nextInt();
System.out.print("Enter constant: ");
c = scanner.nextInt();

double root1 = (-b + Math.sqrt(b * b - 4 * a * c)) / 2 * a;
double root2 = (-b - Math.sqrt(b * b - 4 * a * c)) / 2 * a;

if (root1 == root2)
System.out.println("The root of the quadratic equation is: " + root1);
else
System.out.println("The two roots of the quadratic equation are: " + root1 + " and " + root2);

scanner.close();
}

}
38 changes: 38 additions & 0 deletions Java/Q27.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import java.util.Scanner;

public class Q27 {

static int reverse(int num) {

int sum = 0;

while (num > 0) {
int temp = num % 10;

sum = sum * 10 + temp;
num /= 10;
}

return sum;

}

public static void main(String[] args) {

Scanner scanner = new Scanner(System.in);

System.out.println("Enter the number you want to check for palindrome: ");
int num = scanner.nextInt();

int reversed = reverse(num);

if(reversed == num)
System.out.println(num+" is a palindrome");
else
System.out.println(num+" is not a palindrome");

scanner.close();

}

}