CSE111 Lab Assignment 4 - Fall'24
CSE111 Lab Assignment 4 - Fall'24
Number of Tasks: 11
[Submit all the Coding Tasks (Task 1 to 8) in the Google Form shared on buX
before the next lab. Submit the Tracing Tasks (Task 9 to 11) handwritten to your
Lab Instructors at the beginning of the lab]
[You are not allowed to change the driver codes of any of the tasks]
Task 1
Design the Student class in such a way that it produces the following output.
Driver Code Expected Output
Task 2
Design the Toy class in such a way that it produces the following output
Driver Code Expected Output
Task 4
Write “Student“ class to show the following expected outputs
Note:
❖ A student can’t take any course until the CGPA is set.
❖ A student cannot take more than 4 courses.
❖ A student with CGPA below 3 cannot take more than 3 courses.
Driver Code Expected Output
Task 5
Design the Triangle Class that will produce the following output. We will consider both triangles
to have the same sides if all sides are equal in the same orientation/sequence only.
Types of Triangle:
● Equilateral: When all sides in the same orientation are equal.
● Isosceles: When any two sides of a triangle in the same orientation are equal.
● Scalene: When all sides are of different lengths.
Driver Code Output
Task 7
Design the required class/es so that the following output is generated. Read the following
description:
1. You may assume that to board a bus, a student must have the bus pass, and his/her
destination must match the route of the bus.
2. Additionally, the default maximum capacity of the bus is 2.
Task 8
Design the Student and the Usis class so that the following output is produced.
Note:
● A student's email, password, and login status are null by default while creating an object
of the Student class.
● Your code should satisfy the conditions mentioned in the output only.
● Usis class will have two instance variables: totalAdvisee and an array of Student type to
store the student object. The array will be updated inside advising() method only when
the advising is successful.
● Usis can take at most 5 advisees.
Task 10
1 public class msgClass{
2 public int content;
3 }
4 class FinalT5A{
5 public int sum = 2, y = 1, x = 1;
6 public void methodA(){
7 int x=6, y =0;
8 msgClass myMsg = new msgClass();
9 myMsg.content = this.x;
10 x = x + myMsg.content;
11 this.y = this.y + methodB(myMsg, myMsg.content);
12 System.out.println(x + " " + this.y+ " " + sum);
13 y = this.y/2 + this.x;
14 x = y + sum/2;
15 sum = x + y + myMsg.content;
16 System.out.println(x + " " + y+ " " + sum);
17 }
18 public int methodB(msgClass mg2, int mg1){
19 int x = 0;
20 y = y + mg2.content;
21 mg2.content = y + mg1;
22 x = this.x + 3 + mg1;
23 sum = sum + x + y;
24 System.out.println(this.x + " " + this.y+ " " + sum);
25 mg2.content = sum - mg1 ;
26 return sum;
27 }
28 }
Task 11
1 public class A{
2 public int temp = 3, sum = 9, y = 4, x = 0;
3 public A(){
4 int sum = 7;
5 y = temp - 5;
6 sum = temp + 2;
7 temp-=2;
8 this.x = sum + temp + y;
9 }
10 public A(int y, int temp){
11 y = temp - 1 + x;
12 sum = temp + 2 -x;
13 temp-=2;
14 }
15 public void methodA(int m, int [] n){
16 int x = 0;
17 y = y + m + methodB(x,m);
18 x = this.x + 2 + (++n[0]);
19 sum = sum + x + y;
20 n[0] = sum + 2;
21 System.out.println(n[0] + " " + y+ " " + sum);
22 }
23 public int methodB(int m, int n){
24 int [] y = {0};
25 this.y = y[0] + this.y + m;
26 x = this.y + 2 + temp - n;
27 sum = x + y[0] + this.sum;
28 System.out.println(y[0]+ " "+ temp + " " + sum);
29 return y[0];
30 }
31 }
Task 1
Design the Parcel class in such a way that it produces the following output.
NOTE: For the method calcFee(), if the delivery location is Dhanmondi, then the location
charge will be 50 taka or else it’ll be free. Also, while calculating total fee, if the product weight is
0 the total_fee would also be 0.
Formula: fee = (weight * 20) + location_charge (if any)
Task 2
Design the program to get the output as shown.
Hints:
● Create an array in the Team class to store the player’s object
● Use constructor overloading technique for Team class
public class TeamTester { Output:
public static void main(String[] args) {
Team: Bangladesh
Team b = new Team(); List of players:
b.updateName("Bangladesh"); Name: Mashrafi
Age: 42, Total Matches: 100
Player mashrafi = new Player("Mashrafi", 42, 100); Name: Tamim
b.addPlayer(mashrafi); Age: 35, Total Matches: 70
==============
Player tamim = new Player("Tamim", 35, 70); Team: Australia
b.addPlayer(tamim); List of players:
Name: Ponting
b.printDetail(); Age: 50, Total Matches: 300
System.out.println("=============="); Name: Lee
Age: 49, Total Matches: 200
Team a = new Team("Australia");
Player ponting = new Player("Ponting", 50, 300);
a.addPlayer(ponting);
Player lee = new Player("Lee", 49, 200);
a.addPlayer(lee);
a.printDetail();
}
}
Task 3