Javaassingment VU22CSEN0100736
Javaassingment VU22CSEN0100736
VU22csen0100736
Rajmouli.D
import java.util.Scanner;
if (num > 0) {
System.out.println("It's a Positive number");
} else if (num == 0) {
System.out.println("Zero");
} else {
System.out.println("It's a Negative number");
}}}
import java.util.Scanner;
}
}
import java.util.Scanner;
if (year % 4 == 0) {
if (year % 100 == 0) {
if (year % 400 == 0) {
System.out.println(year + " is a leap year.");
} else {
System.out.println(year + " is not a leap year.");
}
} else {
System.out.println(year + " is a leap year.");
}
} else {
System.out.println(year + " is not a leap year.");
}
}
}
import java.util.Scanner;
}
}
double discriminant = b * b - 4 * a * c;
if (discriminant > 0) {
double root1 = (-b + Math.sqrt(discriminant)) / (2 * a);
double root2 = (-b - Math.sqrt(discriminant)) / (2 * a);
System.out.println("Roots are real and different.");
System.out.println("Root 1= " + root1);
System.out.println("Root 2= " + root2);
} else if (discriminant == 0) {
double root = -b / (2 * a);
System.out.println("Roots are real and same.");
System.out.println("Root= " + root);
} else {
double realPart = -b / (2 * a);
double imaginaryPart = Math.sqrt(-discriminant) / (2 * a);
System.out.println("Roots are complex and imaginary.");
System.out.println("Root 1: " + realPart + " + " + imaginaryPart + "i");
System.out.println("Root 2: " + realPart + " - " + imaginaryPart + "i");
}
}
}
import java.util.Scanner;
if (num > 0) {
System.out.println("It's a Positive number");
} else if (num == 0) {
System.out.println("Zero");
} else {
System.out.println("It's a Negative number");
}}}
public class NaturalNumbers {
public static void main(String[] args) {
for (int i = 1; i <= 10; i++) {
System.out.println(i);
}
}
}
import java.util.Scanner;
//Program that reads in two floating-point numbers and tests whether they are the same up to three decimal places.
if (no1Int==no2Int) {
System.out.println("They are same.");
} else {
System.out.println("They are different.");
}
}
}
import java.util.Scanner;