Answer to Question #246178 in Java | JSP | JSF for Aubrey Eso Jozela

Question #246178
Code a method menus() that returns an int value. This value represents the option the user has chosen from the available menu options. Required: a) Define a Scanner variable to read from the keyboard. b) Define an int value, named option. c) Display a menu in the following format: 1: Add room 2: Display rooms 3: Display problem labs 4: Exit d) Read the user’s option from the keyboard into the variable option. e) Return the option read from the keyboard. 4 Code a method named createVenue(). This method has no parameters, but returns a Venue object. Required: a) Define a Scanner variable to read from the keyboard. b) Define variables for building name, room number and number of seats. Prompt the user to type data values for each of the variables and and read the values from the keyboard. c) Define and create a Venue object from the data read from the keyboard. d) Return this Venue object.
1
Expert's answer
2021-10-04T19:59:47-0400
public class Venue {
	private String buildingName;
	private int roomNumber;
	private int numberOfSeats;


	public Venue() {


	}


	public Venue(String buildingName, int roomNumber, int numberOfSeats) {
		this.buildingName = buildingName;
		this.roomNumber = roomNumber;
		this.numberOfSeats = numberOfSeats;
	}


	public String getBuildingName() {
		return buildingName;
	}


	public void setBuildingName(String buildingName) {
		this.buildingName = buildingName;
	}


	public int getRoomNumber() {
		return roomNumber;
	}


	public void setRoomNumber(int roomNumber) {
		this.roomNumber = roomNumber;
	}


	public int getNumberOfSeats() {
		return numberOfSeats;
	}


	public void setNumberOfSeats(int numberOfSeats) {
		this.numberOfSeats = numberOfSeats;
	}


	@Override
	public String toString() {
		return "Venue [buildingName=" + buildingName + ", roomNumber=" + roomNumber + ", numberOfSeats=" + numberOfSeats
				+ "]";
	}


	public Venue createVenue() {
		Venue venue = new Venue();
		venue.setBuildingName(buildingName);
		venue.setRoomNumber(roomNumber);
		venue.setNumberOfSeats(numberOfSeats);
		return venue;
	}
}

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;


public class Menu {


	public static void main(String[] args) {
		int option = 0;
		String nameOfRoom = " ";
		int roomNumber = 0;
		int numberOfSeats = 0;
		List<Venue> hotel = new ArrayList<Venue>();
		Scanner scan = new Scanner(System.in);
		Scanner input = new Scanner(System.in);
		do {


			System.out.println("1: Add room ");
			System.out.println("2: Display rooms");
			System.out.println("3: Display problem labs");
			System.out.println("4: Exit");
			System.out.println("Do your choise: ");
			option = scan.nextInt();
			System.out.println("You choose: " + menus(option));
			if (option == 1) {
				System.out.println("Please provide name of room and press Enter: ");
				nameOfRoom = input.nextLine();
				System.out.println("Please provide room number and press Enter: ");
				roomNumber = scan.nextInt();
				System.out.println("Please provide number of seats and press Enter: ");
				numberOfSeats = scan.nextInt();
				Venue venue = new Venue(nameOfRoom, roomNumber, numberOfSeats);
				System.out.println(venue.createVenue());
				hotel.add(venue);
			} else if (option == 2) {
				for (Venue v : hotel) {
					System.out.println(v.toString());
				}
			} else if (option == 3) {
				System.out.println("Problem labs is no room is avaliable!");
			}else if (option == 4) {
				System.out.println("Quit..");
			}
		} while (option != 4);
		scan.close();
		input.close();


	}


	public static int menus(int option) {
		return option;
	}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS