Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Need appropriate JUnit tests and Code in Java language . You are planning a road

ID: 3724459 • Letter: N

Question

Need appropriate JUnit tests and Code in Java language .

You are planning a road trip and want to create a playlist of your favorite songs. Assume that the song titles are in an array of strings. Create a shuffle of your songs (permutation of your original songs). Use the Fisher–Yates shuffle algorithm that works in O(n) running time. We will use a method that creates pseudo-random numbers (see end for help) in O(1) running time. The basic idea is to start from the last element, swap it with a randomly selected element from the whole array (including last). In the next step you will consider the array from 0 to n-2 (size reduced by 1), and repeat the process until you reach the first element. Write a program that uses the provided Playlist.txt as input and outputs the shuffled array in a file called LastNameFirstNamePlaylist.txt. Follow the next pseudocode: To shuffle an array a of n elements (indices 0..n-1): for i from n - 1 downto 1 j = random integer with 0 <= j <= i exchange a[j] and a[i] Create appropriate JUnits to test your program.

Playlist.txt file is below song :

12-Bar Original

A Beginning
A Day In The Life
A Hard Day's Night
A Shot Of Rhythm And Blues
A Taste Of Honey
Across The Universe
Act Naturally
Ain't She Sweet
All I've Got To Do
All My Loving
All Things Must Pass
All Together Now
All You Need Is Love
And I Love Her
And Your Bird Can Sing
Anna (Go To Him)
Another Girl
Any Time At All
Ask Me Why
Baby It's You
Baby You're A Rich Man
Baby's In Black
Back In The USSR
Bad Boy
Beautiful Dreamer
Because
Being For The Benefit Of Mr Kite!
Besame Mucho
Birthday
Blackbird
Blue Jay Way
Boys
Can't Buy Me Love
Carnival Of Light
Carol
Carry That Weight
Cayenne
Chains
Child Of Nature
Christmas Time (Is Here Again)
Circles
Clarabella
Come And Get It
Come Together
Cry Baby Cry
Cry For A Shadow
Crying, Waiting, Hoping
Day Tripper
Dear Prudence
Devil In Her Heart
Dig A Pony
Dig It
Dizzy Miss Lizzy
Do You Want To Know A Secret
Doctor Robert
Don't Bother Me
Don't Ever Change
Don't Let Me Down
Don't Pass Me By
Drive My Car
Eight Days A Week
Eleanor Rigby
Etcetera
Every Little Thing
Everybody's Got Something To Hide Except Me And My Monkey
Everybody's Trying To Be My Baby
Fixing A Hole
Flying
For No One
For You Blue
Free As A Bird
From Me To You
Get Back
Getting Better
Girl
Glad All Over
Glass Onion
Golden Slumbers
Good Day Sunshine
Good Morning Good Morning
Good Night
Got To Get You Into My Life
Hallelujah, I Love Her So
Happiness Is A Warm Gun
Hello Little Girl
Hello, Goodbye
Help!
Helter Skelter
Her Majesty
Here Comes The Sun
Here, There And Everywhere
Hey Bulldog
Hey Jude
Hold Me Tight
Honey Don't
Honey Pie
How Do You Do It
I Am The Walrus
I Call Your Name
I Don't Want To Spoil The Party
I Feel Fine
I Forgot To Remember To Forget
I Got A Woman
I Got To Find My Baby
I Just Don't Understand
I Me Mine
I Need You
I Saw Her Standing There
I Should Have Known Better
I Wanna Be Your Man
I Want To Hold Your Hand
I Want To Tell You
I Want You (She's So Heavy)
I Will
I'll Be Back
I'll Be On My Way
I'll Cry Instead
I'll Follow The Sun
I'll Get You
I'm A Loser
I'm Down
I'm Gonna Sit Right Down And Cry (Over You)
I'm Happy Just To Dance With You
I'm Looking Through You
I'm Only Sleeping
I'm So Tired
I'm Talking About You
I've Got A Feeling
I've Just Seen A Face
If I Fell
If I Needed Someone
If You've Got Trouble
In My Life
In Spite Of All The Danger
It Won't Be Long
It's All Too Much
It's Only Love
Johnny B Goode
Julia
Junk
Kansas City/Hey-Hey-Hey-Hey!
Keep Your Hands Off My Baby
Komm, Gib Mir Deine Hand
Lady Madonna
Leave My Kitten Alone
Lend Me Your Comb
Let It Be
Like Dreamers Do
Little Child
Lonesome Tears In My Eyes
Long Tall Sally
Long, Long, Long
Los Paranoias
Love Me Do
Love Of The Loved
Love You To
Lovely Rita
Lucille
Lucy In The Sky With Diamonds
Maggie Mae
Magical Mystery Tour
Mailman, Bring Me No More Blues
March Of The Meanies
Martha My Dear
Matchbox
Maxwell's Silver Hammer
Mean Mr Mustard
Memphis, Tennessee
Michelle
Misery
Money (That's What I Want)
Moonlight Bay
Mother Nature's Son
Mr Moonlight
My Bonnie
No Reply
Nobody's Child
Norwegian Wood (This Bird Has Flown)
Not A Second Time
Not Guilty
Nothin' Shakin'
Now And Then
Nowhere Man
Ob-La-Di, Ob-La-Da
Octopus's Garden
Oh! Darling
Old Brown Shoe
One After 909
Only A Northern Song
Ooh! My Soul
Paperback Writer
Penny Lane
Pepperland
Pepperland Laid Waste
Piggies
Please Mister Postman
Please Please Me
Polythene Pam
PS I Love You
Rain
Real Love
Revolution
Revolution 1
Revolution 9
Rip It Up/Shake, Rattle And Roll/Blue Suede Shoes
Rock And Roll Music
Rocky Raccoon
Roll Over Beethoven
Run For Your Life
Savoy Truffle
Sea Of Holes
Sea Of Monsters
Sea Of Time
Searchin'
September In The Rain
Sexy Sadie
Sgt Pepper's Lonely Hearts Club Band
Sgt Pepper's Lonely Hearts Club Band (Reprise)
She Came In Through The Bathroom Window
She Loves You
She Said She Said
She's A Woman
She's Leaving Home
Shout
Sie Liebt Dich
Slow Down
So How Come (No One Loves Me)
Soldier Of Love
Some Other Guy
Something
Sour Milk Sea
Step Inside Love
Strawberry Fields Forever
Sun King
Sure To Fall (In Love With You)
Sweet Little Sixteen
Take Good Care Of My Baby
Take Out Some Insurance On Me, Baby
Taxman
Teddy Boy
Tell Me What You See
Tell Me Why
Thank You Girl
That Means A Lot
That'll Be The Day
That's All Right (Mama)
The Ballad Of John And Yoko
The Continuing Story Of Bungalow Bill
The End
The Fool On The Hill
The Hippy Hippy Shake
The Honeymoon Song
The Inner Light
The Long And Winding Road
The Night Before
The Saints
The Sheik Of Araby
The Word
There's A Place
Things We Said Today
Think For Yourself
This Boy
Three Cool Cats
Ticket To Ride
Till There Was You
To Know Her Is To Love Her
Tomorrow Never Knows
Too Much Monkey Business
Twist And Shout
Two Of Us
Wait
We Can Work It Out
What Goes On
What You're Doing
What's The New Mary Jane
When I Get Home
When I'm Sixty-Four
While My Guitar Gently Weeps
Why
Why Don't We Do It In The Road?
Wild Honey Pie
With A Little Help From My Friends
Within You Without You
Words Of Love
Yellow Submarine
Yellow Submarine In Pepperland
Yer Blues
Yes It Is
Yesterday
You Can't Do That
You Know My Name (Look Up The Number)
You Know What To Do
You Like Me Too Much
You Never Give Me Your Money
You Really Got A Hold On Me
You Won't See Me
You'll Be Mine
You're Going To Lose That Girl
You've Got To Hide Your Love Away
Young Blood
Your Mother Should Know
(I Can't Get No) Satisfaction
The Last Time
As Tears Go By
Time Is On My Side
It's All over Now
Tell Me
19th Nervous Breakdown
Heart Of Stone
Get Off Of My Cloud
Not Fade Away
Good Times Bad Times
Play With Fire
Time Is on My Side
What A Wonderful World
Cabaret
Dream A Little Dream Of Me
Hello, Dolly!
Our Love Is Here To Stay (With Ella Fitzgerald)
I Gotta Right To Sing The Blues
Georgia On My Mind
When You're Smiling (The Whole World Smiles With You)
On The Sunny Side Of The Street
Mack The Knife
When It's Sleepy Time Down South (Live)
Basin Street Blues
Someday (You'll Be Sorry)
It Takes Two To Tango
Gone Fishin' (With Bing Crosby)
A Kiss To Build A Dream On
That Lucky Old Sun (Just Rolls Around Heaven All Day)
Blueberry Hill
Do You Know What It Means To Miss New Orleans?
I Want A Little Girl
Ain't Misbehavin'
Struttin' With Some Barbeque
When The Saints Go Marching In
No Quarter
Over the Hills and Far Away
Ramble On
Since I've Been Loving You
Somethin' Else
Stairway to Heaven
Tea for One
Ten Years Gone
That's the Way
The Girl I Love (She Got Long Black Wavy Hair)
The Immigrant Song
The Rover
The Song Remains the Same
Trampled Under Foot
Travelling Riverside Blues
Walter's Walk
Wearing and Tearing
What Is and What Should Never Be
You Shook Me
Your Time Is Gonna Come
Poor Tom
Symphony No5:I
1812 Overture
Eine Kleine Nachtmusik: Allegro
Toccata And Fugue In D Minor
William Tell Overture   1829   horses   iTunesiTunes AmazonAmazon
Canon In D   1694   wedding   iTunesiTunes AmazonAmazon
Blue Danube   1866   cartoon   iTunesiTunes AmazonAmazon
Carmina Burana: O Fortuna
Also Sprach Zarathustra
Orpheus In The Underworld: Infernal Galop
Messiah: Hallelujah Chorus
Carmen: Les Toreadors
Gayane: Sabre Dance
Symphony No. 9: Ode To Joy
Pomp And Circumstance March
Peer Gynt: In The Hall Of The Mountain King
La Gioconda: Dance Of The Hours
Hungarian Rhapsody No. 2
Midsummer Night's Dream: Wedding March
Tale Of Tsar Saltan: Flight Of The Bumblebee
Rhapsody In Blue
Moonlight Sonata
Bolero
Nutcracker: Dance Of The Sugar-Plum Fairy
Over The Waves
Air On The G String
Magic Flute: Queen Of The Night
Fuer Elise
Entry Of The Gladiators
Lakme: Flower Duet
Sorcerer's Apprentice
Rodeo: Hoedown
Die Walkuere: Ride Of The Valkyries
Cantata 147: Jesu, Joy Of Man's Desiring
Nutcracker: Waltz Of The Flowers
Carmen: Habanera
Suite Bergamasque: Clair De Lune
Funeral March
Piano Sonata No. 11: Rondo Alla Turca
Night On Bald Mountain
Minuet   1771
Peer Gynt: Morning Mood
Marriage Of Figaro Overture
Stars And Stripes Forever
Lohengrin: Bridal Chorus
Four Seasons: Spring
Minuet In G
Adagio For Strings
Nutcracker: Dance Of The Mirlitons (Reed Flutes)
Imperial March   1980   powerful   iTunesiTunes AmazonAmazon
Bugler's Dream
Cello Suite No. 1
Barber Of Seville: Largo Al Factotum (Figaro)
Nutcracker: Trepak (Russian Dance)
Rondeau
Lullaby
Minuet In G
Rhapsody On A Theme Of Paganini, 18th Variation
Fanfare For The Common Man
Piano Concerto No. 1
Thieving Magpie Overture
Symphony No. 9: II
Hungarian Dance No. 5
Piano Sonata No. 16
Solomon: Arrival Of The Queen Of Sheba
Nutcracker: Tea (Chinese Dance)
Brandenburg Concerto No. 3: I
Peter And The Wolf: The Story Begins
Romeo And Juliet Fantasy Overture
Rigoletto: La Donna È Mobile
Palladio
Carnival Of The Animals: Aquarium
Piano Concerto
Nutcracker: March
Requiem: Dies Irae
Light Cavalry Overture
Bourrée In E Minor
Skater's Waltz
Four Seasons: Winter
Carnival Of The Animals: Finale
Swan Lake: Scene
Symphony No. 40: I
Barber Of Seville Overture
Planets: Mars, The Bringer Of War
Washington Post
Il Trovatore: Anvil Chorus
Requiem: Lacrimosa
Tritsch-Tratsch Polka
Water Music: Alla Hornpipe
Romeo And Juliet: Montagues And Capulets (Dance Of The Knights)
Piano Concerto No. 21
Symphony No. 7: II
Sylvia: Pizzicato
Colonel Bogey March
Liebestraum No. 3
Turandot: Nessun Dorma
Magic Flute Overture
Requiem: Dies Irae
Symphony No. 9 (New World): IV
Radetzky March

Explanation / Answer

import java.util.Random;
import java.util.Scanner;

public class Playlist
{
static String[] fisherYatesShuffling(String []arr, int n)
{
String []a = new String[n];
int []ind = new int[n];
for(int i=0; i<n; i++)
ind[i] = 0;
int index;
Random rand = new Random();
for(int i=0; i<n; i++)
{
do
{
index = rand.nextInt(n);
} while(ind[index] != 0);

ind[index] = 1;
a[i] = arr[index];
}
return a;
}

public static void main(String agrs[])
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter the size of your playlist: ");
int n = sc.nextInt();
System.out.println("Enter the songs: ");
String []a = new String[n];
String[]res = new String[n];
for(int i=0; i<n; i++)
{
a[i] = sc.next();
}
res = fisherYatesShuffling(a, n);
for(int i=0; i<n; i++)
{
System.out.print(res[i]+" ");
}
sc.close();
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote