Assignment 02 - 24301482 - S.M. Fuad Hasan
Assignment 02 - 24301482 - S.M. Fuad Hasan
T2
public class GradeChecker {
public static void main(String[] args) {
int s7 = 82;
if (s7 >= 90 && s7 <= 100) {
System.out.println("Your grade is A");
} else if (s7 >= 85) {
System.out.println("Your grade is A-");
} else if (s7 >= 70) {
System.out.println("Your grade is B");
} else if (s7 >= 57) {
System.out.println("Your grade is C");
} else if (s7 >= 50) {
System.out.println("Your grade is D");
} else {
System.out.println("Your grade is F");
}
}
}
t3
T4
public class LeapYearChecker {
public static void main(String[] args) {
int yr5 = 1900;
if (yr5 % 400 == 0) {
System.out.println(yr5 + " is a leap year");
} else if (yr5 % 100 == 0) {
System.out.println(yr5 + " is not a leap year");
} else if (yr5 % 4 == 0) {
System.out.println(yr5 + " is a leap year");
} else {
System.out.println(yr5 + " is not a leap year");
}
}
}
T5
public class NumberTypeChecker {
public static void main(String[] args) {
int k8 = 5;
if (k8 < 0) {
System.out.println("Number is negative");
} else if (k8 == 0) {
System.out.println("Number is zero");
} else if (k8 % 2 == 0) {
System.out.println("Number is positive and even");
} else {
System.out.println("Number is positive and odd");
}
}
}
T6
public class PiecewiseFunction {
public static void main(String[] args) {
int i9 = 4;
if (i9 < 0) {
System.out.println("output: " + (2 * i9));
} else if (i9 <= 2) {
System.out.println("output: " + (i9 + 1));
} else if (i9 <= 6) {
System.out.println("output: " + (3 * i9 + 3));
} else {
System.out.println("output: " + (50 * i9 - 198));
}
}
}
T8
public class TaxCalculator {
public static void main(String[] args) {
int salary4 = 30000, age6 = 25;
double tax6 = 0;
T9
public class MinMaxFinder {
public static void main(String[] args) {
double d1 = 18.83, d2 = -4.02, d3 = 83.12;
double max1 = Math.max(d1, Math.max(d2, d3));
double min1 = Math.min(d1, Math.min(d2, d3));
T10
T11
T12
T13
T14
T15