SlideShare a Scribd company logo
1 of 12
Download to read offline
Many of us have large digital music collections that are not always very well organized. It would
be nice to have a program that would manipulate our music collection based on attributes such as
artist, album title, song title, genre, song length, number times played, and rating. For this
assignment you will write a basic digital music manager (DMM).
Your DMM program must have a text-based interface which allows the user to select from a
mainmenu of options including: (1) load, (2) store, (3) display, (4) insert, (5) delete, (6) edit, (7)
sort, (8) rate, (9) play, (10) shuffle, and (11) exit. For Part I of the assignment, you will only need
to complete the main menu, (1) load, (2) store, (3) display, (6) edit, (8) rate, (9) play, and (11)
exit features. The other features will be completed in the next part of the assignment.
What must the main menu contain?
The main menu must display the following commands:
(1) load
(2) store
(3) display
(4) insert
(5) delete
(6) edit
(7) sort
(8) rate
(9) play
(10) shuffle
(11) exit
After a command is selected and completed, your program must display the main menu again.
This procedure will continue until the “exit” command is selected.
What must “load” do?
The “load” command must read all records from a file called musicPlayList.csv (you may find a
sample file here) into a dynamic doubly linked list. The doubly linked list is considered the main
playlist. As each record is read from the file, it must be inserted at the front of the list. Each
record consists of the following attributes:
Each attribute, in a single record, will be separated by a comma in the .csv (comma separated
values) file. This means that you will need to design an algorithm to extract the required
attributes for each record. Each field in each record will have a value. You do not need to check
for null or empty values.
You must define a struct called Record to represent the above attributes. Also, do not forget that
the Song Length must be represented by another struct called Duration. Duration is defined as
follows:
Finally, each struct Node in the doubly linked list must be defined as follows:
What must “store” do?
The “store” command writes the current records, in the dynamic doubly linked list, to the
musicPlayList.csv file. The store will completely overwrite the previous contents in the file.
What must “display” do?
The “display” command prints records to the screen. This command must support two methods,
one of which is selected by the user:
Print all records.
Print all records that match an artist.
What must “edit” do?
The “edit” command must allow the user to find a record in the list by artist. If there are multiple
records with the same artist, then your program must prompt the user which one to edit. The user
may modify all of the attributes in the record.
What must “rate” do?
The “rate” command must allow the user to assign a value of 1 – 5 to a song; 1 is the lowest
rating and 5 is the highest rating. The rating will replace the previous rating.
What must “play” do?
The “play” command must allow the user to select a song, and must start “playing” each song in
order from the current song. “Playing” the song for this assignment means displaying the
contents of the record that represents the song for a short period of time, clearing the screen and
showing the next record in the list, etc. This continues until all songs have been played.
What must “exit” do?
The “exit” command saves the most recent list to the musicPlayList.csv file. This command will
completely overwrite the previous contents in the file.
IV. Logical Block Diagram
The logical block diagram for your doubly linked list should look like the following:
As you can see from the illustration a doubly linked list has a pointer to the next node and the
previous node in the list. The first node’s previous node pointer is always NULL and the last
node’s next pointer is always NULL. When you insert and delete nodes from a doubly linked list,
you must always carefully link the previous and next pointers.
Solution
#include
#include
#include
#define strlength 25;
struct node {
struct node *prev;
char artist[strlength];
char albumtitle[strlength];
char songtitle[strlength];
char genre[strlength];
int songlen;
int num_ts_played;
int rating;
struct node *next;
} *h, *temp, *temp1, *temp2, *temp4, *temp3;
void insert();
void delete();
void sort();
void edit();
void store(int);
void load();
void display();
void rate();
int count = 0;
int count1=0;
void main()
{
int ch;
h = NULL;
temp = temp1 = NULL;
printf(" 1 - load");
printf(" 2 - store");
printf(" 3 - display");
printf(" 4 - insert");
printf(" 5 - delete");
printf(" 6 - sort");
printf(" 7 - edit");
printf(" 8 - rate");
printf(" 9 - exit");
while (1)
{
printf(" Enter choice : ");
scanf("%d", &ch);
switch (ch)
{
case 1:
load();
break;
case 2:
store();
break;
case 3:
display();
break;
case 4:
insert();
sort();
break;
case 5:
delete();
break;
case 6:
sort();
break;
case 7:
edit();
break;
case 8:
rate();
break;
case 9:
exit(0);
break;
default:
printf(" Wrong choice menu");
}
}
}
/* TO create an empty node */
void create()
{
int data;
temp = (struct node *)malloc(sizeof(struct node));
temp->prev = NULL;
temp->next = NULL;
printf("Artist Name: ");
scanf("%s", temp->artist);
printf("Album title: ");
scanf("%s", temp->albumtitle);
printf("Song title: ");
scanf("%s", temp->songtitle);
printf("Generic name: ");
scanf("%s", temp->genre);
printf("Length of the song: ");
scanf("%d", temp->songlen);
printf("Number of times played: ");
scanf("%d", temp->num_ts_played);
printf("Rating: ");
scanf("%d", temp->rating);
count++;
}
/* TO insert at beginning */
void insert1()
{
if (h == NULL)
{
create();
h = temp;
temp1 = h;
}
else
{
create();
temp->next = h;
h->prev = temp;
h = temp;
}
}
/* To delete an element */
void delete()
{
int i = 1;
char song[strlength];
printf(" Enter title of the song : ");
scanf("%s", song);
temp2 = h;
if (strcmp(temp2->songtitle, song) == 0)
{
printf(" Error : Position out of range to delete");
return;
}
if (h == NULL)
{
printf(" Error : Empty list no elements to delete");
return;
}
else
{
while (temp2->songtitle, song)
== 0)
{
temp2 = temp2->next;
i++;
}
if (i == 1)
{
if (temp2->next == NULL)
{
printf("Node deleted from list");
free(temp2);
temp2 = h = NULL;
return;
}
}
if (temp2->next == NULL)
{
temp2->prev->next = NULL;
free(temp2);
printf("Node deleted from list");
return;
}
temp2->next->prev = temp2->prev;
if (i != 1)
temp2->prev->next = temp2->next; /* Might not need this statement if i
== 1 check */
if (i == 1)
h = temp2->next;
printf(" Node deleted");
free(temp2);
}
count--;
}
/* Traverse from beginning */
void display() {
temp2 = h;
if (temp2 == NULL)
{
printf("List empty to display  ");
return;
}
printf(" Linked list elements from begining : ");
while (temp2->next != NULL)
{
printf(" %s  ", temp2->artist);
printf(" %s  ", temp2->albumtitle);
printf(" %s  ", temp2->songtitle);
printf(" %s  ", temp2->genre);
printf(" %d  ", temp2->songlen);
printf(" %d  ", temp2->num_ts_played);
printf(" %d  ", temp2->rating);
temp2 = temp2->next;
}
printf(" %s ", temp2->songtitle);
}
/* To search for an element in the list */
void search() {
int count = 0;
char artist[strlength];
temp2 = h;
if (temp2 == NULL)
{
printf(" Error : List empty to search for data");
return;
}
printf(" Enter value to search : ");
scanf("%s", artist);
while (temp2 != NULL)
{
if (strcmp(temp2->artist, artist) == 0)
{
printf(" Data found in %d position", count + 1);
return;
}
else
temp2 = temp2->next;
count++;
}
printf(" Error : %d not found in list", data);
}
/* To update a node value in the list */
void edit()
{
char album[strlength];
char album1[strlength];
printf(" Enter album title to be updated : ");
scanf("%d", &album);
printf(" Enter new data : ");
scanf("%d", &album1);
temp2 = h;
if (temp2 == NULL)
{
printf(" Error : List empty no node to update");
return;
}
while (temp2 != NULL)
{
if (strcmp(temp2->albumtitle, album) == 0)
{
temp2->albumtitle = album;
display();
return;
}
else
temp2 = temp2->next;
}
printf(" Error : %d not found in list to update", data);
}
/* To sort the linked list */
void sort()
{
int i, j, x;
temp2 = h;
temp4 = h;
temp3 = h;
if (temp2 == NULL)
{
printf(" List empty to sort");
return;
}
for (temp2 = h; temp2 != NULL; temp2 = temp2->next)
{
for (temp4 = temp2->next; temp4 != NULL; temp4 = temp4->next)
{
if (strcmp(temp2->genre, temp4->genre) > 0)
{
temp3 = temp2;
temp2 = temp4;
temp4 = temp3;
}
}
}
display();
}
void load()
{
FILE *fp;
char ch;
fp = fopen("test.txt", "r");
while ((ch = getc(file)) != EOF)
{
temp = (struct node *)malloc(sizeof(struct node));
temp->prev = NULL;
temp->next = NULL;
fscanf("%s", temp->artist);
fscanf("%s", temp->albumtitle);
fscanf("%s", temp->songtitle);
fscanf("%s", temp->genre);
fscanf("%d", temp->songlen);
fscanf("%d", temp->num_ts_played);
fscanf("%d", temp->rating);
temp->next = h;
h->prev = temp;
h = temp;
count1++;
}
fclose(fp);
}
void store()
{
FILE *fp;
temp = (struct node *)malloc(sizeof(struct node));
temp->prev = NULL;
temp->next = NULL;
char ch;
fp = fopen("test.txt", "w");
if (fp)
{
for (i = 0; i <= count1; ++i)
{
fprintf("%s t", temp->artist);
fprintf("%s t", temp->albumtitle);
fprintf("%s t", temp->songtitle);
fprintf("%s t", temp->genre);
fprintf("%d t", temp->songlen);
fprintf("%d t", temp->num_ts_played);
fprintf("%d t", temp->rating);
fprintf(" ");
}
}
fclose(fp);
}
void rate()
{
temp2 = h;
char song[strlength];
int r;
printf("rate the songs: ");
printf("enter the song to rate: ");
scanf("%s", &song);
if (temp2 == NULL)
{
printf("List empty to display  ");
return;
}
while (temp2->next != NULL)
{
if(strcmp(temp2->songtitle,song)==0)
{
printf("enter the rate(1-5): ");
scanf("%d", r);
temp2->rating=r;
}
else
{
temp2=temp2->next;
}
}
}

More Related Content

Similar to Many of us have large digital music collections that are not always .pdf

Program 01 For this program you will complete the program in.pdf
Program 01 For this program you will complete the program in.pdfProgram 01 For this program you will complete the program in.pdf
Program 01 For this program you will complete the program in.pdf
addtechglobalmarketi
 
I am having the below compile errors. .pdf
I am having the below compile errors. .pdfI am having the below compile errors. .pdf
I am having the below compile errors. .pdf
dbrienmhompsonkath75
 
Shell Scripts
Shell ScriptsShell Scripts
Shell Scripts
Dr.Ravi
 
Lecture 3 Perl & FreeBSD administration
Lecture 3 Perl & FreeBSD administrationLecture 3 Perl & FreeBSD administration
Lecture 3 Perl & FreeBSD administration
Mohammed Farrag
 
8.8 Program Playlist (Java)You will be building a linked list. Ma.pdf
8.8 Program Playlist (Java)You will be building a linked list. Ma.pdf8.8 Program Playlist (Java)You will be building a linked list. Ma.pdf
8.8 Program Playlist (Java)You will be building a linked list. Ma.pdf
ARCHANASTOREKOTA
 
lab03build.bat@echo offclsset DRIVE_LETTER=1set.docx
lab03build.bat@echo offclsset DRIVE_LETTER=1set.docxlab03build.bat@echo offclsset DRIVE_LETTER=1set.docx
lab03build.bat@echo offclsset DRIVE_LETTER=1set.docx
DIPESH30
 
For this homework, you will write a program to create and manipulate.pdf
For this homework, you will write a program to create and manipulate.pdfFor this homework, you will write a program to create and manipulate.pdf
For this homework, you will write a program to create and manipulate.pdf
herminaherman
 
It's not working what am I doing wrong- Given main()- complete the Son.pdf
It's not working what am I doing wrong- Given main()- complete the Son.pdfIt's not working what am I doing wrong- Given main()- complete the Son.pdf
It's not working what am I doing wrong- Given main()- complete the Son.pdf
aanyajoshi90
 
Need help with this java project, as the methods are proving to be p.pdf
Need help with this java project, as the methods are proving to be p.pdfNeed help with this java project, as the methods are proving to be p.pdf
Need help with this java project, as the methods are proving to be p.pdf
prajeetjain
 
DevChatt 2010 - *nix Cmd Line Kung Foo
DevChatt 2010 - *nix Cmd Line Kung FooDevChatt 2010 - *nix Cmd Line Kung Foo
DevChatt 2010 - *nix Cmd Line Kung Foo
brian_dailey
 
In C++ please I need output please You will be building a .pdf
In C++ please I need output please   You will be building a .pdfIn C++ please I need output please   You will be building a .pdf
In C++ please I need output please You will be building a .pdf
sunilverma8487
 
819 LAB Program Playlist c++ You will be building a li.pdf
819 LAB Program Playlist c++ You will be building a li.pdf819 LAB Program Playlist c++ You will be building a li.pdf
819 LAB Program Playlist c++ You will be building a li.pdf
meenaaarika
 

Similar to Many of us have large digital music collections that are not always .pdf (20)

Bioinformatica p4-io
Bioinformatica p4-ioBioinformatica p4-io
Bioinformatica p4-io
 
BeepComp - Chiptune Creator - User's Guide (v0.2.2)
BeepComp - Chiptune Creator - User's Guide (v0.2.2)BeepComp - Chiptune Creator - User's Guide (v0.2.2)
BeepComp - Chiptune Creator - User's Guide (v0.2.2)
 
Program 01 For this program you will complete the program in.pdf
Program 01 For this program you will complete the program in.pdfProgram 01 For this program you will complete the program in.pdf
Program 01 For this program you will complete the program in.pdf
 
I am having the below compile errors. .pdf
I am having the below compile errors. .pdfI am having the below compile errors. .pdf
I am having the below compile errors. .pdf
 
Design problem
Design problemDesign problem
Design problem
 
Shell Scripts
Shell ScriptsShell Scripts
Shell Scripts
 
n
nn
n
 
Lecture 3 Perl & FreeBSD administration
Lecture 3 Perl & FreeBSD administrationLecture 3 Perl & FreeBSD administration
Lecture 3 Perl & FreeBSD administration
 
8.8 Program Playlist (Java)You will be building a linked list. Ma.pdf
8.8 Program Playlist (Java)You will be building a linked list. Ma.pdf8.8 Program Playlist (Java)You will be building a linked list. Ma.pdf
8.8 Program Playlist (Java)You will be building a linked list. Ma.pdf
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlab
 
Bioinformatica: Esercizi su Perl, espressioni regolari e altre amenità (BMR G...
Bioinformatica: Esercizi su Perl, espressioni regolari e altre amenità (BMR G...Bioinformatica: Esercizi su Perl, espressioni regolari e altre amenità (BMR G...
Bioinformatica: Esercizi su Perl, espressioni regolari e altre amenità (BMR G...
 
lab03build.bat@echo offclsset DRIVE_LETTER=1set.docx
lab03build.bat@echo offclsset DRIVE_LETTER=1set.docxlab03build.bat@echo offclsset DRIVE_LETTER=1set.docx
lab03build.bat@echo offclsset DRIVE_LETTER=1set.docx
 
For this homework, you will write a program to create and manipulate.pdf
For this homework, you will write a program to create and manipulate.pdfFor this homework, you will write a program to create and manipulate.pdf
For this homework, you will write a program to create and manipulate.pdf
 
It's not working what am I doing wrong- Given main()- complete the Son.pdf
It's not working what am I doing wrong- Given main()- complete the Son.pdfIt's not working what am I doing wrong- Given main()- complete the Son.pdf
It's not working what am I doing wrong- Given main()- complete the Son.pdf
 
Beginning with vi text editor
Beginning with vi text editorBeginning with vi text editor
Beginning with vi text editor
 
Bozorgmeh os lab
Bozorgmeh os labBozorgmeh os lab
Bozorgmeh os lab
 
Need help with this java project, as the methods are proving to be p.pdf
Need help with this java project, as the methods are proving to be p.pdfNeed help with this java project, as the methods are proving to be p.pdf
Need help with this java project, as the methods are proving to be p.pdf
 
DevChatt 2010 - *nix Cmd Line Kung Foo
DevChatt 2010 - *nix Cmd Line Kung FooDevChatt 2010 - *nix Cmd Line Kung Foo
DevChatt 2010 - *nix Cmd Line Kung Foo
 
In C++ please I need output please You will be building a .pdf
In C++ please I need output please   You will be building a .pdfIn C++ please I need output please   You will be building a .pdf
In C++ please I need output please You will be building a .pdf
 
819 LAB Program Playlist c++ You will be building a li.pdf
819 LAB Program Playlist c++ You will be building a li.pdf819 LAB Program Playlist c++ You will be building a li.pdf
819 LAB Program Playlist c++ You will be building a li.pdf
 

More from fazanmobiles

H&M The Challenges of Global Expansion and the Move to adopt Intern.pdf
H&M The Challenges of Global Expansion and the Move to adopt Intern.pdfH&M The Challenges of Global Expansion and the Move to adopt Intern.pdf
H&M The Challenges of Global Expansion and the Move to adopt Intern.pdf
fazanmobiles
 
C++ ProgrammingYou are to develop a program to read Baseball playe.pdf
C++ ProgrammingYou are to develop a program to read Baseball playe.pdfC++ ProgrammingYou are to develop a program to read Baseball playe.pdf
C++ ProgrammingYou are to develop a program to read Baseball playe.pdf
fazanmobiles
 
Discuss the differences between a lists regular iterator, which su.pdf
Discuss the differences between a lists regular iterator, which su.pdfDiscuss the differences between a lists regular iterator, which su.pdf
Discuss the differences between a lists regular iterator, which su.pdf
fazanmobiles
 
C programming Create a system managing a mini library system. Eve.pdf
C programming Create a system managing a mini library system. Eve.pdfC programming Create a system managing a mini library system. Eve.pdf
C programming Create a system managing a mini library system. Eve.pdf
fazanmobiles
 
An analyst has decided to capitalize the operating leases of Company.pdf
An analyst has decided to capitalize the operating leases of Company.pdfAn analyst has decided to capitalize the operating leases of Company.pdf
An analyst has decided to capitalize the operating leases of Company.pdf
fazanmobiles
 
Why is a visual analysis important in communicating findings in a bu.pdf
Why is a visual analysis important in communicating findings in a bu.pdfWhy is a visual analysis important in communicating findings in a bu.pdf
Why is a visual analysis important in communicating findings in a bu.pdf
fazanmobiles
 
What is the role of the financial system Name and describe two mark.pdf
What is the role of the financial system Name and describe two mark.pdfWhat is the role of the financial system Name and describe two mark.pdf
What is the role of the financial system Name and describe two mark.pdf
fazanmobiles
 
True or False Questions1) Good technology transfer between pr.pdf
True or False Questions1) Good technology transfer between pr.pdfTrue or False Questions1) Good technology transfer between pr.pdf
True or False Questions1) Good technology transfer between pr.pdf
fazanmobiles
 

More from fazanmobiles (20)

H&M The Challenges of Global Expansion and the Move to adopt Intern.pdf
H&M The Challenges of Global Expansion and the Move to adopt Intern.pdfH&M The Challenges of Global Expansion and the Move to adopt Intern.pdf
H&M The Challenges of Global Expansion and the Move to adopt Intern.pdf
 
C++ ProgrammingYou are to develop a program to read Baseball playe.pdf
C++ ProgrammingYou are to develop a program to read Baseball playe.pdfC++ ProgrammingYou are to develop a program to read Baseball playe.pdf
C++ ProgrammingYou are to develop a program to read Baseball playe.pdf
 
Discuss the differences between a lists regular iterator, which su.pdf
Discuss the differences between a lists regular iterator, which su.pdfDiscuss the differences between a lists regular iterator, which su.pdf
Discuss the differences between a lists regular iterator, which su.pdf
 
Feasibility is an important issue in security system formulation. Wh.pdf
Feasibility is an important issue in security system formulation. Wh.pdfFeasibility is an important issue in security system formulation. Wh.pdf
Feasibility is an important issue in security system formulation. Wh.pdf
 
CopyPaste the sentence into the text box. Then, insert punctuat.pdf
CopyPaste the sentence into the text box. Then, insert punctuat.pdfCopyPaste the sentence into the text box. Then, insert punctuat.pdf
CopyPaste the sentence into the text box. Then, insert punctuat.pdf
 
C programming Create a system managing a mini library system. Eve.pdf
C programming Create a system managing a mini library system. Eve.pdfC programming Create a system managing a mini library system. Eve.pdf
C programming Create a system managing a mini library system. Eve.pdf
 
estion 47 (1 point) Raul Prebisch, based at the Economic Commission f.pdf
estion 47 (1 point) Raul Prebisch, based at the Economic Commission f.pdfestion 47 (1 point) Raul Prebisch, based at the Economic Commission f.pdf
estion 47 (1 point) Raul Prebisch, based at the Economic Commission f.pdf
 
Dr. Muehls mother was a nurse and her father was a dairy farmer. S.pdf
Dr. Muehls mother was a nurse and her father was a dairy farmer. S.pdfDr. Muehls mother was a nurse and her father was a dairy farmer. S.pdf
Dr. Muehls mother was a nurse and her father was a dairy farmer. S.pdf
 
CHAPTER 19 Reproductive system Disorders 24. List the STD and the org.pdf
CHAPTER 19 Reproductive system Disorders 24. List the STD and the org.pdfCHAPTER 19 Reproductive system Disorders 24. List the STD and the org.pdf
CHAPTER 19 Reproductive system Disorders 24. List the STD and the org.pdf
 
can Fluorescence Resonance Emission Transfer (FRET) Microscopy be us.pdf
can Fluorescence Resonance Emission Transfer (FRET) Microscopy be us.pdfcan Fluorescence Resonance Emission Transfer (FRET) Microscopy be us.pdf
can Fluorescence Resonance Emission Transfer (FRET) Microscopy be us.pdf
 
An analyst has decided to capitalize the operating leases of Company.pdf
An analyst has decided to capitalize the operating leases of Company.pdfAn analyst has decided to capitalize the operating leases of Company.pdf
An analyst has decided to capitalize the operating leases of Company.pdf
 
Why is a visual analysis important in communicating findings in a bu.pdf
Why is a visual analysis important in communicating findings in a bu.pdfWhy is a visual analysis important in communicating findings in a bu.pdf
Why is a visual analysis important in communicating findings in a bu.pdf
 
what usually happens to autoimmune antibody-producing clones dur.pdf
what usually happens to autoimmune antibody-producing clones dur.pdfwhat usually happens to autoimmune antibody-producing clones dur.pdf
what usually happens to autoimmune antibody-producing clones dur.pdf
 
Why platinum and its compounds display a variety of colorSoluti.pdf
Why platinum and its compounds display a variety of colorSoluti.pdfWhy platinum and its compounds display a variety of colorSoluti.pdf
Why platinum and its compounds display a variety of colorSoluti.pdf
 
What is Vertical versus horizontal integration in healthcare W.pdf
What is Vertical versus horizontal integration in healthcare W.pdfWhat is Vertical versus horizontal integration in healthcare W.pdf
What is Vertical versus horizontal integration in healthcare W.pdf
 
What is the role of the financial system Name and describe two mark.pdf
What is the role of the financial system Name and describe two mark.pdfWhat is the role of the financial system Name and describe two mark.pdf
What is the role of the financial system Name and describe two mark.pdf
 
What is the difference between a paired artery and an unpaired arter.pdf
What is the difference between a paired artery and an unpaired arter.pdfWhat is the difference between a paired artery and an unpaired arter.pdf
What is the difference between a paired artery and an unpaired arter.pdf
 
What has Microsoft improved in Windows Server 2012 when it comes to .pdf
What has Microsoft improved in Windows Server 2012 when it comes to .pdfWhat has Microsoft improved in Windows Server 2012 when it comes to .pdf
What has Microsoft improved in Windows Server 2012 when it comes to .pdf
 
What are the steps for developing Developing a Project Scope Stateme.pdf
What are the steps for developing Developing a Project Scope Stateme.pdfWhat are the steps for developing Developing a Project Scope Stateme.pdf
What are the steps for developing Developing a Project Scope Stateme.pdf
 
True or False Questions1) Good technology transfer between pr.pdf
True or False Questions1) Good technology transfer between pr.pdfTrue or False Questions1) Good technology transfer between pr.pdf
True or False Questions1) Good technology transfer between pr.pdf
 

Recently uploaded

SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
Peter Brusilovsky
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
AnaAcapella
 
SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project research
CaitlinCummins3
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
EADTU
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
中 央社
 
Contoh Aksi Nyata Refleksi Diri ( NUR ).pdf
Contoh Aksi Nyata Refleksi Diri ( NUR ).pdfContoh Aksi Nyata Refleksi Diri ( NUR ).pdf
Contoh Aksi Nyata Refleksi Diri ( NUR ).pdf
cupulin
 

Recently uploaded (20)

DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUMDEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
 
Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"
 
The Liver & Gallbladder (Anatomy & Physiology).pptx
The Liver &  Gallbladder (Anatomy & Physiology).pptxThe Liver &  Gallbladder (Anatomy & Physiology).pptx
The Liver & Gallbladder (Anatomy & Physiology).pptx
 
diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
 
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptxAnalyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & Systems
 
How to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptxHow to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptx
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
 
ESSENTIAL of (CS/IT/IS) class 07 (Networks)
ESSENTIAL of (CS/IT/IS) class 07 (Networks)ESSENTIAL of (CS/IT/IS) class 07 (Networks)
ESSENTIAL of (CS/IT/IS) class 07 (Networks)
 
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of TransportBasic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
 
Observing-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptxObserving-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptx
 
SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project research
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
 
UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
 
e-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopale-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopal
 
Contoh Aksi Nyata Refleksi Diri ( NUR ).pdf
Contoh Aksi Nyata Refleksi Diri ( NUR ).pdfContoh Aksi Nyata Refleksi Diri ( NUR ).pdf
Contoh Aksi Nyata Refleksi Diri ( NUR ).pdf
 
Mattingly "AI and Prompt Design: LLMs with NER"
Mattingly "AI and Prompt Design: LLMs with NER"Mattingly "AI and Prompt Design: LLMs with NER"
Mattingly "AI and Prompt Design: LLMs with NER"
 

Many of us have large digital music collections that are not always .pdf

  • 1. Many of us have large digital music collections that are not always very well organized. It would be nice to have a program that would manipulate our music collection based on attributes such as artist, album title, song title, genre, song length, number times played, and rating. For this assignment you will write a basic digital music manager (DMM). Your DMM program must have a text-based interface which allows the user to select from a mainmenu of options including: (1) load, (2) store, (3) display, (4) insert, (5) delete, (6) edit, (7) sort, (8) rate, (9) play, (10) shuffle, and (11) exit. For Part I of the assignment, you will only need to complete the main menu, (1) load, (2) store, (3) display, (6) edit, (8) rate, (9) play, and (11) exit features. The other features will be completed in the next part of the assignment. What must the main menu contain? The main menu must display the following commands: (1) load (2) store (3) display (4) insert (5) delete (6) edit (7) sort (8) rate (9) play (10) shuffle (11) exit After a command is selected and completed, your program must display the main menu again. This procedure will continue until the “exit” command is selected. What must “load” do? The “load” command must read all records from a file called musicPlayList.csv (you may find a sample file here) into a dynamic doubly linked list. The doubly linked list is considered the main playlist. As each record is read from the file, it must be inserted at the front of the list. Each record consists of the following attributes: Each attribute, in a single record, will be separated by a comma in the .csv (comma separated values) file. This means that you will need to design an algorithm to extract the required attributes for each record. Each field in each record will have a value. You do not need to check for null or empty values. You must define a struct called Record to represent the above attributes. Also, do not forget that the Song Length must be represented by another struct called Duration. Duration is defined as
  • 2. follows: Finally, each struct Node in the doubly linked list must be defined as follows: What must “store” do? The “store” command writes the current records, in the dynamic doubly linked list, to the musicPlayList.csv file. The store will completely overwrite the previous contents in the file. What must “display” do? The “display” command prints records to the screen. This command must support two methods, one of which is selected by the user: Print all records. Print all records that match an artist. What must “edit” do? The “edit” command must allow the user to find a record in the list by artist. If there are multiple records with the same artist, then your program must prompt the user which one to edit. The user may modify all of the attributes in the record. What must “rate” do? The “rate” command must allow the user to assign a value of 1 – 5 to a song; 1 is the lowest rating and 5 is the highest rating. The rating will replace the previous rating. What must “play” do? The “play” command must allow the user to select a song, and must start “playing” each song in order from the current song. “Playing” the song for this assignment means displaying the contents of the record that represents the song for a short period of time, clearing the screen and showing the next record in the list, etc. This continues until all songs have been played. What must “exit” do? The “exit” command saves the most recent list to the musicPlayList.csv file. This command will completely overwrite the previous contents in the file. IV. Logical Block Diagram The logical block diagram for your doubly linked list should look like the following: As you can see from the illustration a doubly linked list has a pointer to the next node and the previous node in the list. The first node’s previous node pointer is always NULL and the last node’s next pointer is always NULL. When you insert and delete nodes from a doubly linked list, you must always carefully link the previous and next pointers. Solution #include #include
  • 3. #include #define strlength 25; struct node { struct node *prev; char artist[strlength]; char albumtitle[strlength]; char songtitle[strlength]; char genre[strlength]; int songlen; int num_ts_played; int rating; struct node *next; } *h, *temp, *temp1, *temp2, *temp4, *temp3; void insert(); void delete(); void sort(); void edit(); void store(int); void load(); void display(); void rate(); int count = 0; int count1=0; void main() { int ch; h = NULL; temp = temp1 = NULL; printf(" 1 - load"); printf(" 2 - store"); printf(" 3 - display"); printf(" 4 - insert"); printf(" 5 - delete"); printf(" 6 - sort"); printf(" 7 - edit"); printf(" 8 - rate");
  • 4. printf(" 9 - exit"); while (1) { printf(" Enter choice : "); scanf("%d", &ch); switch (ch) { case 1: load(); break; case 2: store(); break; case 3: display(); break; case 4: insert(); sort(); break; case 5: delete(); break; case 6: sort(); break; case 7: edit(); break; case 8: rate(); break; case 9: exit(0); break; default:
  • 5. printf(" Wrong choice menu"); } } } /* TO create an empty node */ void create() { int data; temp = (struct node *)malloc(sizeof(struct node)); temp->prev = NULL; temp->next = NULL; printf("Artist Name: "); scanf("%s", temp->artist); printf("Album title: "); scanf("%s", temp->albumtitle); printf("Song title: "); scanf("%s", temp->songtitle); printf("Generic name: "); scanf("%s", temp->genre); printf("Length of the song: "); scanf("%d", temp->songlen); printf("Number of times played: "); scanf("%d", temp->num_ts_played); printf("Rating: "); scanf("%d", temp->rating); count++; } /* TO insert at beginning */ void insert1() { if (h == NULL) { create(); h = temp; temp1 = h; }
  • 6. else { create(); temp->next = h; h->prev = temp; h = temp; } } /* To delete an element */ void delete() { int i = 1; char song[strlength]; printf(" Enter title of the song : "); scanf("%s", song); temp2 = h; if (strcmp(temp2->songtitle, song) == 0) { printf(" Error : Position out of range to delete"); return; } if (h == NULL) { printf(" Error : Empty list no elements to delete"); return; } else { while (temp2->songtitle, song) == 0) { temp2 = temp2->next; i++; } if (i == 1) {
  • 7. if (temp2->next == NULL) { printf("Node deleted from list"); free(temp2); temp2 = h = NULL; return; } } if (temp2->next == NULL) { temp2->prev->next = NULL; free(temp2); printf("Node deleted from list"); return; } temp2->next->prev = temp2->prev; if (i != 1) temp2->prev->next = temp2->next; /* Might not need this statement if i == 1 check */ if (i == 1) h = temp2->next; printf(" Node deleted"); free(temp2); } count--; } /* Traverse from beginning */ void display() { temp2 = h; if (temp2 == NULL) { printf("List empty to display "); return; } printf(" Linked list elements from begining : "); while (temp2->next != NULL)
  • 8. { printf(" %s ", temp2->artist); printf(" %s ", temp2->albumtitle); printf(" %s ", temp2->songtitle); printf(" %s ", temp2->genre); printf(" %d ", temp2->songlen); printf(" %d ", temp2->num_ts_played); printf(" %d ", temp2->rating); temp2 = temp2->next; } printf(" %s ", temp2->songtitle); } /* To search for an element in the list */ void search() { int count = 0; char artist[strlength]; temp2 = h; if (temp2 == NULL) { printf(" Error : List empty to search for data"); return; } printf(" Enter value to search : "); scanf("%s", artist); while (temp2 != NULL) { if (strcmp(temp2->artist, artist) == 0) { printf(" Data found in %d position", count + 1); return; } else temp2 = temp2->next; count++; } printf(" Error : %d not found in list", data);
  • 9. } /* To update a node value in the list */ void edit() { char album[strlength]; char album1[strlength]; printf(" Enter album title to be updated : "); scanf("%d", &album); printf(" Enter new data : "); scanf("%d", &album1); temp2 = h; if (temp2 == NULL) { printf(" Error : List empty no node to update"); return; } while (temp2 != NULL) { if (strcmp(temp2->albumtitle, album) == 0) { temp2->albumtitle = album; display(); return; } else temp2 = temp2->next; } printf(" Error : %d not found in list to update", data); } /* To sort the linked list */ void sort() { int i, j, x; temp2 = h; temp4 = h; temp3 = h;
  • 10. if (temp2 == NULL) { printf(" List empty to sort"); return; } for (temp2 = h; temp2 != NULL; temp2 = temp2->next) { for (temp4 = temp2->next; temp4 != NULL; temp4 = temp4->next) { if (strcmp(temp2->genre, temp4->genre) > 0) { temp3 = temp2; temp2 = temp4; temp4 = temp3; } } } display(); } void load() { FILE *fp; char ch; fp = fopen("test.txt", "r"); while ((ch = getc(file)) != EOF) { temp = (struct node *)malloc(sizeof(struct node)); temp->prev = NULL; temp->next = NULL; fscanf("%s", temp->artist); fscanf("%s", temp->albumtitle); fscanf("%s", temp->songtitle); fscanf("%s", temp->genre); fscanf("%d", temp->songlen);
  • 11. fscanf("%d", temp->num_ts_played); fscanf("%d", temp->rating); temp->next = h; h->prev = temp; h = temp; count1++; } fclose(fp); } void store() { FILE *fp; temp = (struct node *)malloc(sizeof(struct node)); temp->prev = NULL; temp->next = NULL; char ch; fp = fopen("test.txt", "w"); if (fp) { for (i = 0; i <= count1; ++i) { fprintf("%s t", temp->artist); fprintf("%s t", temp->albumtitle); fprintf("%s t", temp->songtitle); fprintf("%s t", temp->genre); fprintf("%d t", temp->songlen); fprintf("%d t", temp->num_ts_played); fprintf("%d t", temp->rating); fprintf(" "); } } fclose(fp); } void rate() { temp2 = h;
  • 12. char song[strlength]; int r; printf("rate the songs: "); printf("enter the song to rate: "); scanf("%s", &song); if (temp2 == NULL) { printf("List empty to display "); return; } while (temp2->next != NULL) { if(strcmp(temp2->songtitle,song)==0) { printf("enter the rate(1-5): "); scanf("%d", r); temp2->rating=r; } else { temp2=temp2->next; } } }