Java code X1 Practice ProblemYou are writing a programfor an architectural firm that needs to enter the areasof all the rooms in a building project they’re working on. Some rooms are square, some are round, and some are rectangular. Each room in the building has an ID number to help prevent adding the same room more than once. The program needs to prompt the user for the room ID number, the shape of the room, and the dimensionsneeded to calculate the area. It should store the ID number and the calculated area in sq. ft. (rounded to the nearest foot) of each room in a single integer ArrayList in the order:ID, area, ID, area, ... If the room ID has already been entered, it should let the user know and prompt for another. The program should continue running until the user chooses to close the program. It should also allow the user to view a list of the current rooms’IDs and areas, the total area, and the average room area.The program will need at least the following methods. The only global variable shouldbe a Scanner object.•public static void main(String[] args)controls the flow of the program and manages the integer ArrayList.It will present the user with the choice to enter a new room, view room statistics, or exit the program. If an invalid choice is made, it should just repeat the menu of choices.•public static void getRoomId(ArrayList data)asks the user for the ID of the room they’re reporting on, checks to make sure that ID has not already been entered, and adds the ID to the ArrayList. It should bulletproof input and allow the user to keep trying until a valid, unique ID is entered.•public static int getRoomShape() gets the room shape selection from the user by presenting a numbered menu (such as 1 –square, 2 –round, 3 –rectangular.) It should bulletproof input and allow the user to keep trying until a valid choice is entered.•public static int calcArea(int roomShape)calculates the room area based on the shape of the room selected, prompting the user for the data needed to do the calculation (width for square, diameter for round, length and widthrectangular.)•public static void displayStats(ArrayList data) reads all the data stored in the ArrayList, prints out the entire list of room IDs and areas, followed by the total area of all the rooms added together and the average room area based on the number of rooms currently entered.You are welcome to add more methods if necessary, but you have to have the above methods. The program should be error free and user friendly. Proper indentation and spacing is expected, but you do not have to add JavaDoc comments.
Java code
X1 Practice ProblemYou are writing a programfor an architectural firm that needs to enter the areasof all the rooms in a building project they’re working on. Some rooms are square, some are round, and some are rectangular. Each room in the building has an ID number to help prevent adding the same room more than once. The
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 4 images