How do I make a loop that will allow to add a song again and saving the previos one
Show older comments
fprintf(' Let''s get started! \n');
% Define variables.
RepreProcessA = "No";
RepreProcessD = "No";
RepreProcessE = "No";
SongFound = 0;
RepreProcessAll = "Y";
EditAgain = "Yes";
ModSelection = input(' Will you like to sign in as a User or Administrator? ','s');
while strcmpi(ModSelection ,'User') ~=1 && strcmpi(ModSelection ,'Administrator') ~=1
fprintf(' You have selected a not existing option. \n');
ModSelection = input(' Are you a User or an Administrator ','s');
end
if strcmpi(ModSelection ,'Administrator')
fprintf(' Welcome to the MusicLive hardcore. \n');
% admname = input(' What is your Username? ','s');
% while admname ~= "AdmMusicLive"
% fprintf(' Incorrect username! \n');
% admname = input(' What is your username, NERD!!! ','s');
% end
% fprintf(' Username correct \n');
% admpassword = input(' What is your password? ','s');
% while admpassword ~= "AdmPassword"
% fprintf(' Incorrect password! \n');
% admpassword = input(' What is the correct password, NERD!!! ','s');
% end
% fprintf(' Password correct \n');
% fprintf(' %s, you have successfully entered into hardcode of the software. \n', User_Name);
% fprintf(' You will have access to Add, Delete and Edit the software database. \n');
OptSelection = input(' Will you like to Add, Delete, or Edit a song? ', 's');
while strcmpi(OptSelection,'Add') ~=1 && strcmpi(OptSelection,'Delete') ~=1 ...
&& strcmpi(OptSelection,'Edit') ~=1
fprintf(' You have selected a not existing option \n');
OptSelection = input(' Selected a valid option ','s');
end
%--------------------------------------------------------------------------------
if strcmpi(OptSelection,"Add")
while strcmpi(RepreProcessAll,"Y")
while strcmpi(RepreProcessA,"No")
SongName = input(" What is the song's name? ",'s');
while isempty(SongName)
fprintf(' Invalid name, enter a name with only alphabetical characters \n');
SongName = input(" What is the song's name? ",'s');
end
fprintf(" The name of the new songs was entered correctly \n");
fprintf(" \n");
SongSinger = input(' How is the song''s singer ','s');
while isempty(SongSinger)
fprintf(' Invalid name, enter a name with only alphabetical characters \n');
SongSinger= input(" How is the song''s singer ",'s');
end
fprintf(" The singer of the new songs was entered correctly \n");
fprintf(" \n");
SongTime = input(" What is the song's length in minutes (round to the nearest whole number)? ");
while isempty(SongTime) || SongTime < 0
fprintf(' Error, the value entered is incorrect \n');
SongTime = input(' Please, enter a whole number ');
end
if SongTime <= 2
SongTime = "ShortOpt";
elseif SongTime >= 3
SongTime = "IntermidianOpt";
elseif SongTime >= 4
SongTime = "LongOpt";
end
fprintf(' The new song time was entered successfully. \n');
fprintf(" \n");
fprintf(" Enter the song genre. \n");
fprintf(" The three options for the song's genre are Rock, Pop, and Country. \n");
SongGenre = input(" What is the song's genre? ",'s');
while strcmpi(SongGenre,'Rock') ~=1 && strcmpi(SongGenre,'Pop') ~=1 ...
&& strcmpi(SongGenre,'Country') ~=1
fprintf(' You have selected a not existing option \n');
fprintf(' Selected Rock, Pop, or Country. \n');
SongGenre = input(' Selected the correct option ','s');
fprintf(' The new song genre was entered successfully. \n');
end
fprintf(" The genre of the new songs was entered correctly. \n");
fprintf(" \n");
fprintf(" The three options for the song's language are English, Italian, and Romanian. \n");
SongLanguage = input(" What is the language of the song? ", 's');
while strcmpi(SongLanguage,'English') ~=1 && strcmpi(SongLanguage,'Italian') ~=1 ...
&& strcmpi(SongLanguage,'Romanian') ~=1
fprintf(' You have selected a not existing option NERD!!! \n');
fprintf(' Selected English, Italian, or Romanian. \n');
SongLanguage = input(' Selected the correct option ','s');
end
fprintf(' The new song language was entered successfully. \n');
fprintf(" \n");
fprintf(' The song name is %s \n', SongName);
fprintf(' The song singer is %s \n', SongSinger);
fprintf(' The song time is %s \n', SongTime);
fprintf(' The song genre is %s \n', SongGenre);
fprintf(' The song language is %s \n', SongLanguage);
fprintf(' Selected Yes if desired to save the changes; if not selected No \n');
RepreProcessA = input(' Yes or No ','s' );
while strcmpi(RepreProcessA, 'No') ~= 1 && strcmpi(RepreProcessA, 'Yes') ~= 1
fprintf(' Selected Yes or No NERD!!! \n');
RepreProcessA = input(' Selected Yes if desired to save the changes; if not selected No ','s');
end
NewData = [MusicDatabase; {SongName}, {SongSinger} {SongTime}, {SongGenre}, {SongLanguage}];
writecell(NewData,'Music_Database.xlsx')
end
RepreProcessAll = input(' Selected Y if desired to save the changes; if not selected N ','s');
while strcmpi(RepreProcessAll, 'N') ~= 1 && strcmpi(RepreProcessAll, 'Y') ~= 1
fprintf(' Selected Y or N NERD!!! \n');
RepreProcessAll = input(' Y if desired to save the changes; if not selected N ','s');
% This is not working, I need a obtion that will allow me more songs amd saving the ones that already add.
end
end
Accepted Answer
More Answers (0)
Categories
Find more on Timing and presenting 2D and 3D stimuli in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!