0% found this document useful (0 votes)
27 views5 pages

Assignment 02 - 24301482 - S.M. Fuad Hasan

cse110

Uploaded by

Fuad Hasan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views5 pages

Assignment 02 - 24301482 - S.M. Fuad Hasan

cse110

Uploaded by

Fuad Hasan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 5

T1

public class LargestFinder {


public static void main(String[] args) {
int x9 = 100, y3 = 23, z1 = -4;
if (x9 >= y3 && x9 >= z1) {
System.out.println("largest number: " + x9);
} else if (y3 >= x9 && y3 >= z1) {
System.out.println("largest number: " + y3);
} else {
System.out.println("largest number: " + z1);
}
}
}

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

public class DivisibilityChecker {


public static void main(String[] args) {
int n4 = 105;
if (n4 % 5 == 0 && n4 % 7 == 0) {
System.out.println("Divisible by Both");
} else if (n4 % 5 == 0) {
System.out.println("Invalid: Divisible by 5 Only");
} else if (n4 % 7 == 0) {
System.out.println("Invalid: Divisible by 7 Only");
} else {
System.out.println("No");
}
}
}

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;

if (age6 < 18) {


tax6 = 0;
} else if (salary4 <= 10000) {
tax6 = 0;
} else if (salary4 <= 20000) {
tax6 = salary4 * 0.05;
} else {
tax6 = salary4 * 0.10;
}
System.out.println("Your tax amounts in " + (int)tax6 + " Tk");
}
}

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));

System.out.println("Maximum number is " + max1);


System.out.println("Minimum number is " + min1);
}
}

T10

public class TriangleType {


public static void main(String[] args) {
int a2 = 5, b3 = 5, c1 = 3;

if (a2 == b3 && b3 == c1) {


System.out.println("This is an Equilateral triangle");
} else if (a2 == b3 || b3 == c1 || a2 == c1) {
System.out.println("This is an Isosceles triangle");
} else {
System.out.println("This is a Scalene triangle");
}
}
}

T11

public class ChangeCalculator {


public static void main(String[] args) {
int pay8 = 60, given9 = 500;
int change7 = given9 - pay8;
if (change7 < 0) {
System.out.println("Please pay " + (-change7) + " taka more.");
} else {
System.out.println("The returned amount is " + change7 + " taka.");

int hundred5 = change7 / 100;


change7 %= 100;
int fifty3 = change7 / 50;
change7 %= 50;
int twenty8 = change7 / 20;
change7 %= 20;
int ten6 = change7 / 10;
change7 %= 10;
int five7 = change7 / 5;
change7 %= 5;
int two1 = change7 / 2;
change7 %= 2;
int one4 = change7;
System.out.println("100 taka note: " + hundred5);
System.out.println("50 taka note: " + fifty3);
System.out.println("20 taka note: " + twenty8);
System.out.println("10 taka note: " + ten6);
System.out.println("5 taka coin: " + five7);
System.out.println("2 taka coin: " + two1);
System.out.println("1 taka coin: " + one4);
}
}
}

T12

public class EqualityChecker {


public static void main(String[] args) {
int m4 = 2345, n6 = 2452, p8 = 4532;

if (m4 == n6 && n6 == p8) {


System.out.println("All numbers are equal");
} else if (m4 != n6 && n6 != p8 && m4 != p8) {
System.out.println("All numbers are different");
} else {
System.out.println("Neither all are equal or different");
}
}
}

T13

public class SequencePrinter1 {


public static void main(String[] args) {
int x2 = 24;
while (x2 >= -6) {
System.out.print(x2 + " ");
x2 -= 6;
}
}
}

T14

public class SequencePrinter2 {


public static void main(String[] args) {
for (int j3 = -10; j3 <= 20; j3 += 5) {
System.out.print(j3 + " ");
}
}
}

T15

public class SumAndAverage {


public static void main(String[] args) {
int total9 = 0, counter2 = 1;
while (counter2 <= 200) {
total9 += counter2;
counter2++;
}
double avg1 = total9 / 200.0;
System.out.println("Sum: " + total9);
System.out.println("Average: " + avg1);
}
}

You might also like