Question: f) Copy the following main method in your class, public static void main (String [] arg) { int [] a = {3, 5, 6, 8,

![void main (String [] arg) { int [] a = {3, 5,](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f3c588ee0bc_84866f3c5885b281.jpg)
![6, 8, 12, 13, 16, 17, 18, 20}; int [] b =](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f3c589de0da_84966f3c5894fbef.jpg)
![{18, 16, 19, 3 ,14, 6}; int [] c = {5, 2,](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f3c58add7a2_85066f3c58a4272e.jpg)




f) Copy the following main method in your class,
public static void main (String [] arg) { int [] a = {3, 5, 6, 8, 12, 13, 16, 17, 18, 20}; int [] b = {18, 16, 19, 3 ,14, 6}; int [] c = {5, 2, 4, 3, 1}; // testing initializeArray printArray(a); // print: 3, 5, 6, 8, 12, 13, 16, 17, 18, 20 initializeArray(a); printArray(a); // print: 0, 1, 0, 1, 0, 1, 0, 1, 0, 1 // testing initializeArray printArray(b); // print: 18, 16, 19, 3 ,14, 6 arraySelectionSort (b); printArray(b); // print: 19, 18, 16, 14, 6, 3 // testing factorial System.out.println (factorial (5)); //print: 120 c[0] = factorial (c[0]); c[1] = factorial (c[2]); printArray(c); // print: 120, 24, 4, 3, 1 }
public class Assignment { public static void main(String[] args) { ClassroomSeating classSeating; Student tempStudent; int row, col, rowNum, columnNum; String studentInfo; Scanner scan = new Scanner(System.in); // Ask a user to enter a number of rows for an auditorium seating System.out.println ("Please enter a number of rows for an auditorium seating."); rowNum = scan.nextInt(); // Ask a user to enter a number of columns for an auditorium seating System.out.println ("Please enter a number of columns for an auditorium seating."); columnNum = scan.nextInt(); // instantiate a ClassroomSeating object classSeating = new ClassroomSeating(rowNum, columnNum); System.out.println ("Please enter a student information or enter \"Q\" to quit."); /*** reading a student's information ***/ studentInfo = scan.next(); /* we will read line by line **/ while (!studentInfo.equalsIgnoreCase("Q")){ System.out.println(" A student information is read."); // printing information read from a file. System.out.println(studentInfo); // creating a student object using the student information from a user tempStudent = new Student(studentInfo); // Ask a user to decide where to seat a student by asking // for row and column of a seat System.out.println ("Please enter a row number where the student wants to sit."); row = scan.nextInt(); System.out.println ("Please enter a column number where the student wants to sit."); col = scan.nextInt(); // Checking if the row number and column number are valid // (exist in the theatre that we created.) if (classSeating.checkForBoundaries (row, col) == false) { System.out.println(" row or column number is not valid."); System.out.println ("A student " + tempStudent.getFirstName() + " " + tempStudent.getLastName() + " is not assigned a seat."); } else { // Assigning a seat for a student if (classSeating.assignStudentAt(row,col,tempStudent) == true){ System.out.println(" The seat at row " + row + " and column " + col + " is assigned to the student " + tempStudent.toString()); System.out.println(classSeating); } else { System.out.println(" The seat at row " + row + " and column " + col + " is taken."); } } // Read the next studentInfo System.out.println ("Please enter a student information or enter \"Q\" to quit."); /*** reading a student's information ***/ studentInfo = scan.next(); } } }
Sample Output: (the inputs entered by a user are shown in bold)
Make sure that your program works at least with this scenario.
Please enter a number of rows for an auditorium seating. 3 Please enter a number of columns for an auditorium seating. 3 Please enter a student information or enter "Q" to quit. Mickey-Mouse A student information is read. Mickey-Mouse Please enter a row number where the student wants to sit. 1 Please enter a column number where the student wants to sit. 2 The seat at row 1 and column 2 is assigned to the student M-M. The current seating -------------------- *-*. *-*. *-*. *-*. *-*. M-M. *-*. *-*. *-*. Please enter a student information or enter "Q" to quit. Daisy-Duck A student information is read. Daisy-Duck Please enter a row number where the student wants to sit. 2 Please enter a column number where the student wants to sit. 0 The seat at row 2 and column 0 is assigned to the student D-D. The current seating -------------------- *-*. *-*. *-*. *-*. *-*. M-M. D-D. *-*. *-*. Please enter a student information or enter "Q" to quit. Clarabelle-Cow A student information is read. Clarabelle-Cow Please enter a row number where the student wants to sit. 2 Please enter a column number where the student wants to sit. 1 The seat at row 2 and column 1 is assigned to the student C-C. The current seating -------------------- *-*. *-*. *-*. *-*. *-*. M-M. D-D. C-C. *-*. Please enter a student information or enter "Q" to quit. Max-Goof A student information is read. Max-Goof Please enter a row number where the student wants to sit. 0 Please enter a column number where the student wants to sit. 0 The seat at row 0 and column 0 is assigned to the student M-G. The current seating -------------------- M-G. *-*. *-*. *-*. *-*. M-M. D-D. C-C. *-*. Please enter a student information or enter "Q" to quit. Horace-Horsecollar A student information is read. Horace-Horsecollar Please enter a row number where the student wants to sit. 5 Please enter a column number where the student wants to sit. 1 row or column number is not valid. A student Horace Horsecollar is not assigned a seat. Please enter a student information or enter "Q" to quit. Sylvester-Shyster A student information is read. Sylvester-Shyster Please enter a row number where the student wants to sit. 2 Please enter a column number where the student wants to sit. 0 The seat at row 2 and column 0 is taken. Please enter a student information or enter "Q" to quit. Snow-White A student information is read. Snow-White Please enter a row number where the student wants to sit. -1 Please enter a column number where the student wants to sit. 0 row or column number is not valid. A student Snow White is not assigned a seat. Please enter a student information or enter "Q" to quit. Jiminy-Criket A student information is read. Jiminy-Criket Please enter a row number where the student wants to sit. 0 Please enter a column number where the student wants to sit. 2 The seat at row 0 and column 2 is assigned to the student J-C. The current seating -------------------- M-G. *-*. J-C. *-*. *-*. M-M. D-D. C-C. *-*. Please enter a student information or enter "Q" to quit. Q
1. What This Assignment Is About: Classes (methods and attributes) Objects Arrays of Primitive Values Arrays of Objects . .Recursion for and if Statements .Selection Sort 2. Use the following Guidelines Give identifiers semantic meaning and make them easy to read (examples numStudents, grossPay, etc) User upper case for constants. Use title case (first letter is upper case) for classes. Use lower case with uppercase word separators for all other identifiers (variables, methods, objects) Use tabs or spaces to indent code within blocks (code surrounded by braces). This includes classes, methods, and code associated with ifs, switches and loops. Be consistent with the number of spaces or tabs that you use to indent. Use white space to make your program more readable For each file (class) in your assignment, provide a heading (in comments) which includes: The assignment number. * Its author (your name). . A description of what this program is doing,. 3. Part 1. Primitive Types, Searching, Recursion (35 points). a) Create a class Homework (in a file Homework.java) b) Create a static method initializeArray that receives as a parameter an array of integers Use a for loop and an if statement to put 1s in the odd positions of the array and Os in the even positions c) Create a static method printArray that receives as a parameter an array of integers. Use
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
