Professional Documents
Culture Documents
Java
Java
Java
LEAP YEAR
import java.util.Scanner;
public class LeapYear {
public static void main(String[] args){
int year;
System.out.println("Enter a Year : ");
Scanner sc = new Scanner(System.in);
year = sc.nextInt();
if (((year % 4 == 0) && (year % 100!= 0)) || (year%400 == 0))
System.out.println("Encoded year is a leap year");
else
System.out.println("Encoded year is not a leap year");
}
}
6. WORD EQUIVALENT
7. QUADRANT
import java.util.Scanner;
public class Quadrant {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int a,b;
a = sc.nextInt();
b = sc.nextInt();
if(a > 0 && b > 0)
System.out.print("1st Quadrant");
else if(a < 0 && b > 0)
System.out.print("2nd Quadrant");
else if(a < 0 && b < 0)
System.out.print("3rd Quadrant");
else if(a > 0 && b < 0)
System.out.print("4th Quadrant");
else
System.out.print("Origin");
}
}
8. BMI
import java.util.Scanner;
public class BMI {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
System.out.print("Input weight in KILOGRAM: ");
double weight = sc.nextDouble();
System.out.print("\nInput height in METERS: ");
double height = sc.nextDouble();
double BMI = weight / (height * height);
System.out.print("\nBody Mass Index(BMI) is: " + BMI + " kg/m2");
}
}
9. HEIGHT COMPARISON
import java.util.Scanner;
public class HeightComparison {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int myHeight,friendHeight;
System.out.println("Enter my Height : ");
myHeight = sc.nextInt();
System.out.print("\nEnter Friend Height : ");
friendHeight = sc.nextInt();
import java.util.Scanner;
public class Ascending{
public static void main(String[] args) {
}
}