I want to create an algorithm that will take 6 exclusive names and will show all 6 at random order each time that it will be excecuted. Names will be 1-Jack, 2-Alexa, 3-Helen, 4-Mathew, 5-Katherine, 6-Noa. Switch case should be used as part of the algorithm.

Answers (1)

DGM
DGM on 31 Oct 2021
Edited: DGM on 31 Oct 2021
words = {'banana' 'orange' 'apple' 'peach' 'pear' 'cherry'};
randomizedwords = words(randperm(numel(words)));
fprintf('%s\n',randomizedwords{:})
cherry orange pear peach apple banana
Why you would use switch-case is beyond me. Then again, i don't know what the point of dumping random words to console is either.

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Edited:

DGM
on 31 Oct 2021

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!