You will be writing a Classroom Organizer to help with seating students. In this assignment, you'll...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
You will be writing a Classroom Organizer to help with seating students. In this assignment, you'll be using your knowledge of iteration and arrays to create a program that allows tracking and editing the location of students in a classroom. To do this, you will create and turn in a ClassroomOrganizer.java file that runs code in a main method. You are allowed to create helper methods (and we recommend you do), but only the main is required. Solution Description You will write a single file, ClassroomOrganizer.java. You must use all the kinds of loops explored in L7- L8 at least once. ClassroomOrganizer.java ClassroomOrganizer will simulate a terminal prompt where the user can input commands to edit and print the locations of students. Before describing the commands, we will explore the format of the classroom in the output. Here's an example of the output formatting for a classroom with 2 rows and 4 columns, with some seats assigned: ### # ABC # ##### # DE # FGHI # # J # # KLMNO # # You can observe that the output formatting has the following features: At the top and bottom, as well as between each classroom row, there's a row of #. On the left and right, as well as between each classroom column, there's a column for #. The length (in number of characters) of each column is determined by the student who has the longest name. It should fit that name, as well as one space to the left and one to the right. Columns always have a length of at least 3, even if no student is seated anywhere in that column. Names are always centered. If it's impossible to center it exactly (like DE), one more space will be added to the right of the name in the output. ClassroomOrganizer will receive from console arguments two integers representing the number of rows and columns, which describes the layout of the classroom. You will use a String 2D array to keep track of who is seated at each seat. The top row is 0, and the left-most column is 0. For example, java ClassroomOrganizer 2 4 would create a layout like the one in the output formatting. In the example o Student ABC: row 0, column 0 Student DE: row 0, column 2 o o Student FGHI: row 0, column 3 o Student J: row 1, column 0 o Student KLMNO: row 1, column 2 If any of the rows' or columns' inputs are invalid (note: there must be at least one seat in the classroom), the program will print an error message "Invalid classroom size" and finish the program. o Note: while the inputs aren't always valid, they are guaranteed to be two integers. This will also apply to all inputs in the program: the input format will always be valid, but the integer values may not be. Tip: You can use Integer.parseInt, which is the int-equivalent to the Double.parseDouble from lecture. Until the program finishes, the program will ask for a command by printing "> " and allowing the user to input a command through console input in the same line. The program will execute the command (or print an error message), and, if the program didn't finish, ask for a command again. If the command is quit, the program will finish without further output. If the command is print, the program should print the current classroom seating assignment, following the output formatting described above. If the command is go: o A go command always has the following format (without the brackets): go to [row] [column] [name] (name doesn't have spaces) o It will place a student (who can be in another seat or outside the classroom) into the seat at the location of the appropriate row or column o If it fails, it will print one of the following errors: If the student was already there, the error is: "[name] is already there" If another student was there, the error is: "[other student name] is there" If the location is invalid, the error is: "Invalid location" o If it succeeds, and the classroom isn't full, it will print nothing. o If it succeeds and the classroom is now full, it will print "Classroom is full", followed by the classroom seats (same output as print), and finish the program. If the command is move: o A move command is always one of the following (without the brackets): move up [name], move down [name], move left [name], move right [name] (name doesn't have spaces) Recommended Methods While not required, we recommend you use helper methods (methods that "support" main or other methods) to structure your program. We provide the following list of methods (all of which should be static methods, like those in L9). This is an example of methods that you could write (but feel free to structure your program differently!). o It will move a student who is in the classroom into a seat relative to the current location of the student, based on their current location (for example, move up would move a student in location 10 to location 0 0) o If it succeeds (the student location changed), it prints nothing. Otherwise, it will print one of the following errors: If the student is not in the classroom, the error is "[name] is not in the classroom" If another student was in the new location, the error is "[other student name] is there" If the new location is invalid, the error is "Invalid location" boolean isClassroom Full (String[][] classroom) void handleGo (String[][] classroom, int row, int column, String name) void handleMove (String[][] classroom, String direction, String name) void printClassroom (String[] [] classroom) int[] calculateColumn Lengths (String[][] classroom) void printSeparator Row(int length) void printClassroom Row (String[] classroomRow, int[] columnLengths) String centered (String name, int columnLength) Example Output 1 - User Input is Bolded. Your program should look exactly like this. java command: java ClassroomOrganizer 21 > print ***** # > go to 1 0 Alice > print ********* # # Alice # **** > go to 0 0 Bob classroom is full ********* # Bob # # Alice # *** Example Output 2 - User Input is Bolded. Your program should look exactly like this. java command: java ClassroomOrganizer 44 > go to 1 1 Alice > go to 2 1 Bob > go to 1 2 Charlie > go to 2 2 Dave > print ###* # # ########## # ###* # #### # # # Alice # Charlie # # # # Bob # Dave # # > move left Bob > move down Alice # > move right Dave > move up Charlie > print ##: # # # # # ## # Bob # Alice # #### # # # Charlie # # # > move right Dave Invalid location > move left Alice Bob is there > quit # # # # # # # # Dave # ### # Rubric [100] ClassroomOrganizer.java [90] Several scenarios (not necessarily all weighted equally). Each scenario is scored all- or-nothing, depending on whether the input/output matches the solution. . [10] Other checks o [2.5] x 4: Uses each kind of loop at least once. We reserve the right to adjust the rubric, but this is typically only done for correcting mistakes. Allowed Imports To prevent trivialization of the assignment, you are only allowed to import java.util.Scanner. You are not allowed to import any other classes or packages. Feature Restriction There are a few features and methods in Java that overly simplify the concepts we are trying to teach. For that reason, do not use any of the following in your final submission: var (the reserved keyword) Checkstyle The Checkstyle deduction limit for this assignment is 5 points, not counting Javadoc errors. Refer to the course guide for the use of Checkstyle and review the autograder Checkstyle report on your submissions. Collaboration Collaboration Statement To ensure that you acknowledge a collaboration and give credit where credit is due, we require that you place a collaboration statement as a comment at the top of at least one .java file that you submit. That collaboration statement should say either: I worked on the homework assignment alone, using only course materials. or In order to help learn course concepts, I worked on the homework with [give the names of the people you worked with], discussed homework topics and issues with [provide names of people], and/or consulted related material that can be found at [cite any other materials not provided as course materials for CS 1331 that assisted your learning]. If the autograder encounters issues processing your collaboration statement, begin it with "Collaboration Statement: ". Turn-In Procedure Upload the files listed below to the corresponding assignment on Gradescope: ClassroomOrganizer.java For each submission, you will be able to see the results of a few basic test cases on your code. Each test typically corresponds to a rubric item, and the score returned represents the performance of your code on those rubric items only. If you fail a test, you can look at the output to determine what went wrong and resubmit once you have fixed the issue. Important Notes Non-compiling files will receive a 0 for all associated rubric items Do not submit .class files or .jar files Test your code in addition to the basic checks on Gradescope Submit every file each time you resubmit Read the "Allowed Imports" and "Restricted Features" to avoid losing points Check on Piazza for a note containing all official clarifications You will be writing a Classroom Organizer to help with seating students. In this assignment, you'll be using your knowledge of iteration and arrays to create a program that allows tracking and editing the location of students in a classroom. To do this, you will create and turn in a ClassroomOrganizer.java file that runs code in a main method. You are allowed to create helper methods (and we recommend you do), but only the main is required. Solution Description You will write a single file, ClassroomOrganizer.java. You must use all the kinds of loops explored in L7- L8 at least once. ClassroomOrganizer.java ClassroomOrganizer will simulate a terminal prompt where the user can input commands to edit and print the locations of students. Before describing the commands, we will explore the format of the classroom in the output. Here's an example of the output formatting for a classroom with 2 rows and 4 columns, with some seats assigned: ### # ABC # ##### # DE # FGHI # # J # # KLMNO # # You can observe that the output formatting has the following features: At the top and bottom, as well as between each classroom row, there's a row of #. On the left and right, as well as between each classroom column, there's a column for #. The length (in number of characters) of each column is determined by the student who has the longest name. It should fit that name, as well as one space to the left and one to the right. Columns always have a length of at least 3, even if no student is seated anywhere in that column. Names are always centered. If it's impossible to center it exactly (like DE), one more space will be added to the right of the name in the output. ClassroomOrganizer will receive from console arguments two integers representing the number of rows and columns, which describes the layout of the classroom. You will use a String 2D array to keep track of who is seated at each seat. The top row is 0, and the left-most column is 0. For example, java ClassroomOrganizer 2 4 would create a layout like the one in the output formatting. In the example o Student ABC: row 0, column 0 Student DE: row 0, column 2 o o Student FGHI: row 0, column 3 o Student J: row 1, column 0 o Student KLMNO: row 1, column 2 If any of the rows' or columns' inputs are invalid (note: there must be at least one seat in the classroom), the program will print an error message "Invalid classroom size" and finish the program. o Note: while the inputs aren't always valid, they are guaranteed to be two integers. This will also apply to all inputs in the program: the input format will always be valid, but the integer values may not be. Tip: You can use Integer.parseInt, which is the int-equivalent to the Double.parseDouble from lecture. Until the program finishes, the program will ask for a command by printing "> " and allowing the user to input a command through console input in the same line. The program will execute the command (or print an error message), and, if the program didn't finish, ask for a command again. If the command is quit, the program will finish without further output. If the command is print, the program should print the current classroom seating assignment, following the output formatting described above. If the command is go: o A go command always has the following format (without the brackets): go to [row] [column] [name] (name doesn't have spaces) o It will place a student (who can be in another seat or outside the classroom) into the seat at the location of the appropriate row or column o If it fails, it will print one of the following errors: If the student was already there, the error is: "[name] is already there" If another student was there, the error is: "[other student name] is there" If the location is invalid, the error is: "Invalid location" o If it succeeds, and the classroom isn't full, it will print nothing. o If it succeeds and the classroom is now full, it will print "Classroom is full", followed by the classroom seats (same output as print), and finish the program. If the command is move: o A move command is always one of the following (without the brackets): move up [name], move down [name], move left [name], move right [name] (name doesn't have spaces) Recommended Methods While not required, we recommend you use helper methods (methods that "support" main or other methods) to structure your program. We provide the following list of methods (all of which should be static methods, like those in L9). This is an example of methods that you could write (but feel free to structure your program differently!). o It will move a student who is in the classroom into a seat relative to the current location of the student, based on their current location (for example, move up would move a student in location 10 to location 0 0) o If it succeeds (the student location changed), it prints nothing. Otherwise, it will print one of the following errors: If the student is not in the classroom, the error is "[name] is not in the classroom" If another student was in the new location, the error is "[other student name] is there" If the new location is invalid, the error is "Invalid location" boolean isClassroom Full (String[][] classroom) void handleGo (String[][] classroom, int row, int column, String name) void handleMove (String[][] classroom, String direction, String name) void printClassroom (String[] [] classroom) int[] calculateColumn Lengths (String[][] classroom) void printSeparator Row(int length) void printClassroom Row (String[] classroomRow, int[] columnLengths) String centered (String name, int columnLength) Example Output 1 - User Input is Bolded. Your program should look exactly like this. java command: java ClassroomOrganizer 21 > print ***** # > go to 1 0 Alice > print ********* # # Alice # **** > go to 0 0 Bob classroom is full ********* # Bob # # Alice # *** Example Output 2 - User Input is Bolded. Your program should look exactly like this. java command: java ClassroomOrganizer 44 > go to 1 1 Alice > go to 2 1 Bob > go to 1 2 Charlie > go to 2 2 Dave > print ###* # # ########## # ###* # #### # # # Alice # Charlie # # # # Bob # Dave # # > move left Bob > move down Alice # > move right Dave > move up Charlie > print ##: # # # # # ## # Bob # Alice # #### # # # Charlie # # # > move right Dave Invalid location > move left Alice Bob is there > quit # # # # # # # # Dave # ### # Rubric [100] ClassroomOrganizer.java [90] Several scenarios (not necessarily all weighted equally). Each scenario is scored all- or-nothing, depending on whether the input/output matches the solution. . [10] Other checks o [2.5] x 4: Uses each kind of loop at least once. We reserve the right to adjust the rubric, but this is typically only done for correcting mistakes. Allowed Imports To prevent trivialization of the assignment, you are only allowed to import java.util.Scanner. You are not allowed to import any other classes or packages. Feature Restriction There are a few features and methods in Java that overly simplify the concepts we are trying to teach. For that reason, do not use any of the following in your final submission: var (the reserved keyword) Checkstyle The Checkstyle deduction limit for this assignment is 5 points, not counting Javadoc errors. Refer to the course guide for the use of Checkstyle and review the autograder Checkstyle report on your submissions. Collaboration Collaboration Statement To ensure that you acknowledge a collaboration and give credit where credit is due, we require that you place a collaboration statement as a comment at the top of at least one .java file that you submit. That collaboration statement should say either: I worked on the homework assignment alone, using only course materials. or In order to help learn course concepts, I worked on the homework with [give the names of the people you worked with], discussed homework topics and issues with [provide names of people], and/or consulted related material that can be found at [cite any other materials not provided as course materials for CS 1331 that assisted your learning]. If the autograder encounters issues processing your collaboration statement, begin it with "Collaboration Statement: ". Turn-In Procedure Upload the files listed below to the corresponding assignment on Gradescope: ClassroomOrganizer.java For each submission, you will be able to see the results of a few basic test cases on your code. Each test typically corresponds to a rubric item, and the score returned represents the performance of your code on those rubric items only. If you fail a test, you can look at the output to determine what went wrong and resubmit once you have fixed the issue. Important Notes Non-compiling files will receive a 0 for all associated rubric items Do not submit .class files or .jar files Test your code in addition to the basic checks on Gradescope Submit every file each time you resubmit Read the "Allowed Imports" and "Restricted Features" to avoid losing points Check on Piazza for a note containing all official clarifications
Expert Answer:
Related Book For
Accounting for Decision Making and Control
ISBN: 978-0078025747
8th edition
Authors: Jerold Zimmerman
Posted Date:
Students also viewed these algorithms questions
-
A closed tank contains oil with a specific gravity 0.85. If the gauge pressure at a point 10 feet below the oil surface is 23. 7 psi (lb/in.2), determine the absolute pressure and gauge pressure (in...
-
New Jersey Designs is a large merchandiser of apparel for budget-minded families. Management recently became concerned about the amount of inventory carrying costs and transportation costs between...
-
You are the manager of a firm that produces and markets a generic type of soft drink in a competitive market. In addition to the large number of generic products in your market, you also compete...
-
A \(27-\mathrm{kg}\) child stands in the center of a trampoline. (a) If the trampoline center is \(0.32 \mathrm{~m}\) lower than before they got on, what is the spring constant of the trampoline? (b)...
-
Amber Manufacturing produces ceramic teapots. Amber allocates overhead based on the number of direct labor hours. The company is looking into using a standard cost system and has developed the...
-
A student addresses a bully mocking another student, " what you're doing isn't even clever or funny, everyone has a right ti express who they are.. you know like we say every morning.. liberty and...
-
In preprocessing training data for the deep learning model, why do we need to shuffle the data? a. To prepare for a stateful Deep Neural Network. b. To make it easier to create batches. c. To...
-
If the future value of an ordinary, 7-year annuity is $9,000 and interest rates are 9.0 percent, what's the future value of the same annuity due? (Round your answer to 2 decimal places.)
-
What are the differences between cash and accrual basis accounting? Provide an example of each. Accrual accounting requires adjusting entries. Provide an example of an adjusting entry.
-
Is the July salary for its store manager an administrative expense?2.What about payment of utility services for June and July?3.What about a post-filing bonus to the store manager paid on December...
-
What was the average first-day return on IPOs for the period 1980?2015 in the United States? TABLE 19.3 Average First-Day Returns, Categorized by Sales, for IPOs: 1980-2015- 1980-1989 1990-1998...
-
With the use of practical examples discuss the following: A. Performance measurement and organizational vision (8 Marks) B. Responsibility accounting and segmented reporting (10 Marks) C. Financial...
-
BigZag Facing ZigZag Chandrima was thinking of a way out desperately. At least she needs a break! For the last two weeks, she has been working hard to settle some office issues and worked up to...
-
Write a program to move a signed number from smaller register to bigger register. Hint: movzx ax, bl Topic: Data Related Operators and Directives in assembly language
-
Eastern University faces a shortage of parking spaces and charges for parking. For nearby parking (e. g., behind the business school), faculty and staff pay $ 180 per year. Parking in lots Z and B,...
-
The current years income statement for Sants Brakes Co. on a variable costing basis appears in the accompanying table. Inventories of finished stock were increased during the year in anticipation of...
-
Rothwell Inc. is the leader in computer- integrated manufacturing and factory automation products and services. The Rothwell product offering is segmented into 15 product categories, based on product...
-
How the duration of a sprint can be decided?
-
Why estimating software development effort is so difficult? What are the obstacles?
-
How to find associations in the text of a use case?
Study smarter with the SolutionInn App