I want to ask the user to "Enter an event title" but I also want to program to break if they enter a title that already exists within an array. Currently its only doing this after price, and num of participants are entered. Any ideas?
ive attatched a photo of my code but will also copy it here as well 🙂
do {
System.out.println("Add More? (Y/N)");
char prompt = sc.next().charAt(0);
if (prompt == 'n' || prompt == 'N'){
break;
}
else if (prompt == 'y' || prompt == 'Y') {
System.out.println("Enter the title of the event:");
sc.nextLine();
String title = sc.nextLine();
System.out.println("Enter the price per person:");
int price = sc.nextInt();
System.out.println("Enter the number of participants:");
int quantity = sc.nextInt();
// EventToBook event = new EventToBook();
event.setTitle(title);
event.setQuantity(quantity);
event.setPrice(price);
success = booking.addEventToBook(event);
// if(success){
// // System.out.println(event.toString());
// booking.printTotal();}
//wrote this here to tally up after each entry but later saw that this might not be
}
} while (success);
booking.printTotal();
}