Write a program that lists all ways people can line up for a photo (all permutations...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a program that lists all ways people can line up for a photo (all permutations of a list of Strings). The program will read a list of one word names into ArrayList name List (until -1), and use a recursive method to create and output all possible orderings of those names separated by a comma, one ordering per line. When the input is: Julia Lucas Mia -1 then the output is (must match the below ordering): Julia, Lucas, Mia Julia, Mia, Lucas Lucas, Julia, Mia Lucas, Mia, Julia Mia, Julia, Lucas Mia, Lucas, Julia 484924.3417574.qx3zay7 LAB ACTIVITY 4 public class PhotoLineups { 4567 8 9 10 11 12 13. 14 15 16 25 8.11.1: LAB: All permutations of names 17 18. 19} 20 } // TODO: Write method to create and output all permutations of the list of names. public static void printAllPermutations (ArrayList<String> permList, ArrayList<String> nameList) { PhotoLineups.java public static void main(String[] args) { Scanner scnr = new Scanner (System.in); ArrayList<String> namelist = new ArrayList<String>(); ArrayList<String> permList = new ArrayList<String>(); String name; Develop mode // TODO: Read a list of names into namelist; stop when -1 is read. Then call recursive method. } Submit mode Load default template... 0/10 Run your program as often as you'd like, before submitting for grading. Below, type any needed input values in the first box, then click Run program and observe the program's output in the second box. 8.10 LAB: Fibonacci sequence (recursion) The Fibonacci sequence begins with 0 and then 1 follows. All subsequent values are the sum of the previous two, for example: 0, 1, 1, 2, 3, 5, 8, 13. Complete the fibonacci() method, which takes in an index, n, and returns the nth value in the sequence. Any negative index values should return -1. Ex: If the input is: 7 the output is: fibonacci (7) is 13. Note: Use recursion and DO NOT use any loops. 4849243417574.qx3zay7 LAB ACTIVITY 1 import java.util.Scanner; 2 3 public class LabProgram { 6 7 14 15 8.10.1: LAB: Fibonacci sequence (recursion) 16} 17 public static int fibonacci(int n) { /* Type your code here. */ } public static void main(String[] args) { Scanner scnr = new Scanner(System.in); int startNum; } startNum scnr.nextInt(); System.out.println("fibonacci(" + startNum + ") is " + fibonacci (startNum)); Develop mode Submit mode Run program Enter program input (optional) If your code requires input values, provide them here. LabProgram.java Program output displayed here Run your program as often as you'd like, before submitting for grading. Below, type any needed input values in the first box, then click Run program and observe the program's output in the second box. Input (from above) →→→ LabProgram.java (Your program) 0/10 Load default template... Output (shown below) Write a program that lists all ways people can line up for a photo (all permutations of a list of Strings). The program will read a list of one word names into ArrayList name List (until -1), and use a recursive method to create and output all possible orderings of those names separated by a comma, one ordering per line. When the input is: Julia Lucas Mia -1 then the output is (must match the below ordering): Julia, Lucas, Mia Julia, Mia, Lucas Lucas, Julia, Mia Lucas, Mia, Julia Mia, Julia, Lucas Mia, Lucas, Julia 484924.3417574.qx3zay7 LAB ACTIVITY 4 public class PhotoLineups { 4567 8 9 10 11 12 13. 14 15 16 25 8.11.1: LAB: All permutations of names 17 18. 19} 20 } // TODO: Write method to create and output all permutations of the list of names. public static void printAllPermutations (ArrayList<String> permList, ArrayList<String> nameList) { PhotoLineups.java public static void main(String[] args) { Scanner scnr = new Scanner (System.in); ArrayList<String> namelist = new ArrayList<String>(); ArrayList<String> permList = new ArrayList<String>(); String name; Develop mode // TODO: Read a list of names into namelist; stop when -1 is read. Then call recursive method. } Submit mode Load default template... 0/10 Run your program as often as you'd like, before submitting for grading. Below, type any needed input values in the first box, then click Run program and observe the program's output in the second box. 8.10 LAB: Fibonacci sequence (recursion) The Fibonacci sequence begins with 0 and then 1 follows. All subsequent values are the sum of the previous two, for example: 0, 1, 1, 2, 3, 5, 8, 13. Complete the fibonacci() method, which takes in an index, n, and returns the nth value in the sequence. Any negative index values should return -1. Ex: If the input is: 7 the output is: fibonacci (7) is 13. Note: Use recursion and DO NOT use any loops. 4849243417574.qx3zay7 LAB ACTIVITY 1 import java.util.Scanner; 2 3 public class LabProgram { 6 7 14 15 8.10.1: LAB: Fibonacci sequence (recursion) 16} 17 public static int fibonacci(int n) { /* Type your code here. */ } public static void main(String[] args) { Scanner scnr = new Scanner(System.in); int startNum; } startNum scnr.nextInt(); System.out.println("fibonacci(" + startNum + ") is " + fibonacci (startNum)); Develop mode Submit mode Run program Enter program input (optional) If your code requires input values, provide them here. LabProgram.java Program output displayed here Run your program as often as you'd like, before submitting for grading. Below, type any needed input values in the first box, then click Run program and observe the program's output in the second box. Input (from above) →→→ LabProgram.java (Your program) 0/10 Load default template... Output (shown below)
Expert Answer:
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
1. Calculate the mass and mass moment of inertia of the roller using basic principles (theoretically). 2. Calculate the linear and angular velocities and accelerations of the roller using the results...
-
In 2020, Soup Corporation, a C corporation, has earnings of $100,000. It paid $20,000 in dividends to its sole shareholder, Grace. Grace also has a restaurant, Sandwich Caf, which she operates as a...
-
For the Dupit Corp. case study introduced in Section 11.4, the management science team was able to apply a variety of queueing models by making the following simplifying approximation. Except for the...
-
St . Petersburg Graduate School of Management ( GSOM ) in russia . now you required to Analyze the landscape and competitive market of our school ( you will need to choose from which market you are...
-
A hydrogen atom in a 3p state is placed in a uniform external magnetic field B. Consider the interaction of the magnetic field with the atom's orbital magnetic dipole moment. (a) What field magnitude...
-
A recent study asked U.S. adults to name 10 historic events that occurred in their lifetime that have had the greatest impact on the country. The most frequently chosen answer was the September 11,...
-
Consider the National Football League data in Table B.1. Build a linear regression model relating the number of games won to the yards gained rushing by opponents $x_{8}$, the percentage of rushing...
-
How is the number of factors decided in most EFA programs?
-
How do ethical leaders integrate ethical considerations into strategic decision-making processes, balancing short-term business objectives with long-term ethical imperatives to ensure sustainable...
-
Handy Howard's Incorporated, is a student co-op. Handy Howard uses a perpetual Inventory system, The following transactions (summarized) have been selected for analysis: a. Sold merchandise for cash...
-
Miss Campbell is the CEO of Bowdin Corp. Lately, she feels her company lacks the process of determining the organization's long-term objectives and establishing goals. Furthermore, she does not...
-
What is the significance of working capital for a company's daily operations?
-
Is a car manufacturer unreasonable (and therefore negligent) under product liability for making a car without side airbags as standard equipment for everyone in the front and rear seats?
-
John is 26 years old, drinks at a local bar until he he is in ten sheets of wind. John purchases from Joe, a friend at the bar 8 cases of salami. Joe know John is blitzed. John slept in the parking...
-
You have completed the course and are nearing the end of the semester. For this last journal entry I want you to continue putting all the pieces of the course together. For Journal 11 I asked you to...
-
You are about to set up a conveyancing practice. List and explain at least 6 policies and 3 procedures you would need to implement as part of your operations
-
For the equilibrium Br2( g )+Cl2( g )?2BrCl( g ) at 400 K, K c = 7.0. Part A If 0.25 mol of Br2 and0.55 mol of Cl2 are introduced into a3.0-L container at 400 K, what will be the...
-
Evaluate the integral, if it exists. Jo y(y + 1) dy
-
During the 2012 tax year, Irma incurred the following expenses: Union dues..............................................................$275 Tax return preparation...
-
Teresa is a civil engineer who uses her automobile for business. Teresa drove her automobile a total of 21,732 miles during 2012, of which 95 percent was business mileage. The actual cost of...
-
Rebecca and Walter Bunge have been married for 5 years. They live at 883 Scrub Brush Street, Apt. 52B, Las Vegas, NV 89125. Rebecca is a homemaker and Walt is a high school teacher. Rebecca's Social...
-
You are studying survival times for mice given a drug at one of three doses (Low, Medium, or High). You define two dummy variables: (a) With these definitions, write the expressions for the mean...
-
The data in Table 8.25 were collected in order to study factors affecting the supply and demand for commercial air travel. Data on various aspects of commercial air travel for an arbitrarily chosen...
-
It is beneficial to be able to estimate the yield of useful product of a tree based on measurements of the tree taken before it is harvested. Measurements on four such variables were taken on a...
Study smarter with the SolutionInn App