Question 2 (3 points): Code Review and Bug Identification
Below is a Java method from the Travel Booking website. Identify 6 errors related to coding
conventions, coding standards, or coding logic.
public class TravelBooking {
String BookingId;
double totalPrice;
int numberOfTravelers;
}
TravelBooking(String id, double price, int travelers) {
Bookingld = id;
totalPrice = price;
numberOfTravelers = travelers;
boolean ConfirmBooking(String paymentMethod) {
}
}
if (paymentMethod == "CreditCard") {
return processPayment(totalPrice);
} else if (paymentMethod.equals("Digital Wallet")) {
return processPayment(totalPrice * 0.98); // 2% discount
return false;
private boolean processPayment(double amount) {
// Simulate payment processing
return amount > 0;
}
String getBookingDetails() {
}
return "Booking ID: " + BookingId + ", Total: " + totalPrice;
Answer requirements:
Identify 6 errors in the above code.