Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program that lists all ways people can line up for a photo (all permutations of a list of Strings). The program will

Write a program that lists all ways people can line up for a photo (all permutations of a list of Strings). 8.10 LAB: Fibonacci sequence (recursion) The Fibonacci sequence begins with 0 and then 1 follows. All

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 permList, ArrayList nameList) { PhotoLineups.java public static void main(String[] args) { Scanner scnr = new Scanner (System.in); ArrayList namelist = new ArrayList (); ArrayList permList = new ArrayList (); 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)

Step by Step Solution

3.46 Rating (156 Votes )

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Income Tax Fundamentals 2013

Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill

31st Edition

1111972516, 978-1285586618, 1285586611, 978-1285613109, 978-1111972516

More Books

Students also viewed these Programming questions

Question

Explain all drawbacks of application procedure.

Answered: 1 week ago

Question

Evaluate the integral, if it exists. Jo y(y + 1) dy

Answered: 1 week ago