Professional Documents
Culture Documents
LEARNING OUTCOME
MATERIALS
MS WORD
ANY JAVA IDE or ONLINE COMPILER
ACTIVITY
You choose: b
Max of 2 books only. Add again? [Y] Yes [N] No: Y
You choose: e
Computer Programming 2
Web Applications
You choose: a
You choose: e
Page 2 of 7
You have chosen:
Information Management
Software Engineering
Penalty is 50.00!
Book/s returned!
Note: The students (pair) shall submit their program codes and screenshot (during
runtime) to TBL hub until MARCH 27, 2023 Monday.
Page 3 of 7
Source Code:
import java.util.ArrayList;
import java.util.Scanner;
if (transactionType.equalsIgnoreCase("B")) {
borrowBooks(scanner, borrowerType, borrowerName);
} else if (transactionType.equalsIgnoreCase("R")) {
returnBooks(scanner, borrowerType, borrowerName);
} else {
System.out.println("Invalid transaction type.");
}
}
switch (bookChoice.toLowerCase()) {
case "a":
borrowedBooks.add("Information Management");
break;
case "b":
borrowedBooks.add("Mobile Applications");
break;
case "c":
borrowedBooks.add("Data Structures");
break;
case "d":
Page 4 of 7
borrowedBooks.add("Design and Algorithms");
break;
case "e":
borrowedBooks.add("Software Engineering");
break;
default:
System.out.println("Invalid book choice.");
break;
}
// Calculate penalty
double penalty = borrowerType == 1 ? daysLate * 10.00 : 0.00;
System.out.println("Penalty is " + String.format("%.2f", penalty)
+ "!");
}
}
Page 5 of 7
Output 1 – Student Borrowing
Page 6 of 7
Output 3 – Borrowing Teacher
Page 7 of 7