Code example for Scanner

Methods: nextLine

0
	{ 
		Server server = Server.getRandomServer();
		System.out.println("Your server is " + server.getName());
		 
		Menu menu = new Menu(MenuItem.getItems());	
		ArrayList<MenuItem> choices = menu.getUserChoices(scanner);
		if (choices == null)
			return false; 
		 
		Bill bill = new Bill(choices);
		 
		System.out.print("View bill? (y/n): ");
		bill.printBill(scanner.nextLine().equals("y"));		
		double tip = bill.getUserPayment(scanner);
		server.addTips(tip);
		 
		System.out.println(server.getName() + "'s tips:  " + server.getTips());
		 
		return true; 
	} 
Experience pair programming with AI  Get Codota for Java