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...
-
1. Compute Accel's Companies' current ratio at May 31, 2018 and 2017. 2. Did Accel's Companies' current ratio improve, deteriorate, or hold steady during 2018? Accel's Companies, a home improvement...
-
Answer parts (A) and (B ) in Example 7 for fixed costs of $250 per day and total costs of $3,450 per day at an output of 80 skateboards per day. Data from Example 7 The management of a company that...
-
Sketch (by hand) the graphs of each of the following functions over four periods. Then sketch the extensions of each of the functions as both an even and odd periodic function. Determine the...
-
In recent years, Farr Company has purchased three machines. Because of frequent employee turnover in the accounting department, a different accountant was in charge of selecting the depreciation...
-
Dear Tutors , Please Help me with Assignment. 1. In your own words, define environmental audit. * Your answer 2. Name some law that covers mining industries in the Philippines * Your answer 3. What...
-
Jack Tasker opened his Auto Repair Shop in November 2023. The balance sheet at November 30, 2023, prepared by an inexperienced part-time bookkeeper, is shown below. Required Prepare a correct balance...
-
A YEARS 1 2 3 B DEPOSITS@THE BEGGING OF A YEAR $100 $100 $150 $25 0 $25 0 $20 0 $10 4 $200 5 $400 $50 You should evaluate the value if these financial flows at the beginning of the first year...
-
A two-branch parallel circuit has branch impedances Z 1 = 2.0 j5.0 and Z 2 = 1.0 + j1.0 . Obtain the complete power triangle for the circuit if the 2.0- resistor consumes 20 W.
-
Discuss why strategic job analysis is important for organizations to remain competitive. How important are strategic job analyses for SHRM activities? Explain your answer.
-
What are the functions in (a) executing, (b) recording, and (c) custody of payroll transactions?
-
What does it mean to say that a search method is monotonic? How desirable is this property? Which of the search methods described in this chapter is monotonic?
-
a. Identify the specific internal accounting control objectives for each function associated with the recording of sales transactions. b. Indicate an appropriate segregation of duties for these...
-
Intro It is the end of 2024. You plan to complete a Ph.D. in 5 years. Your favorite uncle has promised to help you with your school expenses by giving you the following amounts for Christmas: Year...
-
What is the difference between adsorption and absorption?
-
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...
-
Calculate \(\frac{12}{25} \times \frac{10}{21}\).
-
1. Calculate \(\frac{4}{21} \div \frac{6}{35}\). 2. Calculate \(\frac{1}{8} \div \frac{5}{28}\).
-
Calculate \(3.45 \div 2.341\) using a calculator. Round to three decimal places if necessary.
Study smarter with the SolutionInn App