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

Using C Language, write a digital music manager (DMM) program Your DMM program m

ID: 3665041 • Letter: U

Question

Using C Language, write a digital music manager (DMM) program

Your DMM program must have a text-based interface which allows the user to select from a menu of options including: load, store, display, insert, delete, edit, sort, rate, and exit. The “load” option reads records from a file into a dynamic doubly linked list. The “store” command writes records, in a dynamic doubly linked list, to a file. “Display” prints records, and its attributes to the screen. This command must print either all records or a single record based on a search field. A search field may be any of the attributes belonging to a record. If a search field matches multiple records, then print the first match to the screen. The “insert” option collects information for each new song record and attributes from the user. The new song record must be placed into the list based on a selected sort option. By default, songs are inserted into the list alphabetically (‘a’ – ‘z’) according to artist. Other possible “sort” options include alphabetical ordering based on genre, or increasing numeric value based on rating. “Delete” removes a record from the list. Deletion is based on song title. The “edit” option must allow the user to find a record in the list with any search field. The user may modify any of the attributes in the record. The “rate” action 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. Lastly, “exit” saves the most recent list to a file.

A record is a struct type which consists of the following attributes:

Explanation / Answer


#include<iostream>
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<string.h>

typedef struct sngLen
{
int sngSec;
int sngMin;
}sngLen;

typedef struct SngRecord
{
char artName[50];
char abTitle[50];
char sng_Title[50];
char sng_genre1[50];
sngLen* sngLn1;
int play_Times1;
int sngRng1;
}SngRecord;

typedef struct DoubleListNode
{
SngRecord* record;
struct DoubleListNode* nextLink;
struct DoubleListNode* prevLink;
} ;
DoubleListNode* headNODE=NULL;
DoubleListNode* tailNODE=NULL;

DoubleListNode* createNode(SngRecord* rec)
{
DoubleListNode* temp_node=(DoubleListNode*)malloc(sizeof(DoubleListNode)); temp_node->record=rec;
temp_node->nextLink=NULL; temp_node->prevLink=NULL;
return temp_node;
}

void FILE_LOAD(char* f_name)
{
FILE* fp1=fopen(f_name,"r");
SngRecord* rec=(SngRecord*)malloc(sizeof(SngRecord));
DoubleListNode* headNODE=NULL,*prevLink=NULL;
DoubleListNode* temp1;
if(fp1==NULL) return ;
while(1)
{

if(fgets(rec->artName,50,fp1)!=NULL);
else break;
if(fgets(rec->abTitle,50,fp1)!=NULL);
else break;
if(fgets(rec->sng_Title,50,fp1)!=NULL);
else break;
if(fgets(rec->sng_genre1,50,fp1)!=NULL);
else break;
if(fscanf(fp1,"%d",&rec->sngLn1->sngSec)!=EOF);
else break;
if(fscanf(fp1,"%d",&rec->sngLn1->sngMin)!=EOF);
else break;
if(fscanf(fp1,"%d",&rec->play_Times1)!=EOF);
else break;
if(fscanf(fp1,"%d",&rec->sngRng1)!=EOF);
else break;
temp1=createNode(rec);
if(headNODE==NULL)
{
       temp1->prevLink=NULL;
       temp1->nextLink=NULL;
       headNODE=temp1;
       tailNODE=temp1;
}
   temp1->nextLink=NULL;
   tailNODE->nextLink=temp1;
   temp1->prevLink=tailNODE;
   tailNODE=temp1;   
}
fclose(fp1);
}

void store(char* f_name)
{
   DoubleListNode* temp1;
   FILE* fp1=fopen(f_name,"a");
   if(fp1==NULL)return;
   temp1=headNODE;
   while(temp1)
   {
       fprintf(fp1,"%s ",headNODE->record->artName);
       fprintf(fp1,"%s ",headNODE->record->abTitle);
       fprintf(fp1,"%s ",headNODE->record->sng_Title);
       fprintf(fp1,"%s ",headNODE->record->sng_genre1);
       fprintf(fp1,"%d ",headNODE->record->sngLn1->sngSec);
       fprintf(fp1,"%d ",headNODE->record->sngLn1->sngMin);
       fprintf(fp1,"%d ",headNODE->record->play_Times1);
       fprintf(fp1,"%d ",headNODE->record->sngRng1);
       temp1=temp1->nextLink;
   }
   fclose(fp1);
}

void doubleLISTDisplay()
{
   DoubleListNode* t=headNODE;
   printf("Linked List:");
   while(t!=NULL)
   {
       printf("ArtistName :%s ",headNODE->record->artName);
printf("abTitle:%s ",headNODE->record->abTitle);
printf("sng_Title:%s ",headNODE->record->sng_Title);
printf("sng_genre1:%s ",headNODE->record->sng_genre1);
printf("Second:%d ",headNODE->record->sngLn1->sngSec);
printf("sngMin:%d ",headNODE->record->sngLn1->sngMin);
printf("play_Times1:%d ",headNODE->record->play_Times1);
printf("sngRng1:%d ",headNODE->record->sngRng1);
       t=t->nextLink;
   }
}

void insert()
{
SngRecord* rec=(SngRecord*)malloc(sizeof(SngRecord));
DoubleListNode* t;
printf("ENTER ARTIST NAME : ");
scanf("%s",rec->artName);
printf("ENTER ALBUM TITLE : ");
scanf("%s",rec->abTitle);
printf("ENTER SONG : ");
scanf("%s",rec->sng_Title);
printf("ENTER GENRE : ");
scanf("%s",rec->sng_genre1);
printf("ENTER SONG LENGTH : ");
printf("ENTER SECOMNDS : ");
scanf("%d",&rec->sngLn1->sngSec);
printf("ENTER MIN : ");
scanf("%d",&rec->sngLn1->sngMin);
printf("ENTER TIMES : ");
scanf("%d",&rec->play_Times1);
printf("ENTER RATING : ");
scanf("%d",&rec->sngRng1);
t=createNode(rec);
if(headNODE==NULL)
{
       t->prevLink=NULL;
       t->nextLink=NULL;
       headNODE=t;
       tailNODE=t;
}
   t->nextLink=NULL;
   tailNODE->nextLink=t;
   t->prevLink=tailNODE;
   tailNODE=t;
}


void deleteNODE(char* tle)
{
   DoubleListNode* t=headNODE, *found;
   while((t->nextLink!=NULL)&&(strcmp(t->record->sng_Title,tle)!=0))
   {
       t=t->nextLink;
   }
   if(t->nextLink==NULL)
   {
       return;
   }
   DoubleListNode *temp;
   temp = t -> nextLink;
   t->nextLink = temp->nextLink;
   temp->prevLink = t;
   free(temp);
   headNODE=t;
}

void edit()
{
   int search_Val;
   int val1;
   char artName[50];
   char tle[50];
   char s[50];
   int i=0;
   int sngRng1;
printf("ENTER THE FIELD BASED ON WHICH YOU WANT TO FIND THE RECORD ");
printf("1. ARTNAME, 2. ALBUM TITLE,3.SONG TITLES, 4.GENER, 5.SNGRNG1S");

scanf("%d",search_Val);

if(search_Val==1||search_Val==2||search_Val==3||search_Val==4)
{
scanf("%s",s);
}
else {
scanf("%d",&val1);
}
switch(search_Val)
{
case 1:
   while(headNODE)
   {
   if(strcmp(headNODE->record->artName,s)==0)
   {
       printf("Enter new artName ");

       scanf("%s",artName);

       for(i=0;i<strlen(artName);i++)
       {
           headNODE->record->artName[i]=artName[i];
       }
       headNODE->record->artName[i]='';
       break;
   }
   headNODE=headNODE->nextLink;
   }
   case 2:
   while(headNODE)
   {
   if(strcmp(headNODE->record->abTitle,s)==0)
   {
       printf("ENTER NEW ALBUM TITLE ");


       scanf("%[^ ]s",tle);
       for(i=0;i<strlen(tle);i++)
       {
           headNODE->record->abTitle[i]=tle[i];
       }
       headNODE->record->abTitle[i]='';
       break;
   }
   headNODE=headNODE->nextLink;
   }
   case 3:
   while(headNODE)
   {
   if(strcmp(headNODE->record->sng_Title,s)==0)
   {
       printf("ENTER SONG TITLE ");

       scanf("%[^ ]s",tle);
       for(i=0;i<strlen(tle);i++)
       {
           headNODE->record->sng_Title[i]=tle[i];
       }
       headNODE->record->sng_Title[i]='';
       break;
   }
   headNODE=headNODE->nextLink;
   }
   case 4:
   while(headNODE)
   {
   if(strcmp(headNODE->record->sng_genre1,s)==0)
   {
       printf("ENTER GENRE ");

       scanf("%[^ ]s",tle);

       for(i=0;i<strlen(tle);i++)
       {
           headNODE->record->sng_genre1[i]=tle[i];
       }
       headNODE->record->sng_genre1[i]='';
       break;
   }
   headNODE=headNODE->nextLink;
   }
   case 5:
   while(headNODE)
   {
   if(headNODE->record->sngRng1==val1)
   {
       printf("ENTR RATING ");

       scanf("%d",&sngRng1);
       if(sngRng1>=1&&sngRng1<=5)
       headNODE->record->sngRng1=sngRng1;
       else
       {
       continue;
       }
       break;
   }
   headNODE=headNODE->nextLink;
   }
default: break;
}
}
int main()
{
int USer_Choice1;
char user_file_name[50];
char song[50];
   while(1)
   {
  
printf("1. FILE_LOAD 2.INSERT 3. EDIT, 4. DELETE 5.DISPLAY, 6.STORE(EXIT) ");
printf("PLEASE ENTER YOUR USER_CHOICE1 ");
scanf("%d",&USer_Choice1);

switch(USer_Choice1)
{
case 1:
   {
   printf("ENTER FILENAME ");

   scanf("%s",user_file_name);
   FILE_LOAD(user_file_name);
   break;
   }
case 2:
   {
   insert();
   break;
   }
case 3:
     
   if(headNODE==NULL)
   {
       printf("ENTER FILENAME ");
       scanf("%s",user_file_name);
   FILE_LOAD(user_file_name);
       edit();
   }
   else
   {
       edit();
       break;
   }
     
case 4:
   {
   if(headNODE==NULL)
   {
       printf("PLEASE, FIRST LOAD THE FILE YOU WANT ");
               printf("ENTER THE FILE NAME YOU WANT TO LOAD : ");
       scanf("%s",user_file_name);
   FILE_LOAD(user_file_name);
       deleteNODE(song);
       break;
   }
   else{
       printf("ENTER SONG NAME ");
       scanf("%s",song);
deleteNODE(song);
break;
}
}
case 5:
{
if(headNODE==NULL)
{
printf("PLEASE, FIRST LOAD THE FILE YOU WANT ");
               printf("ENTER THE FILE NAME YOU WANT TO LOAD : ");
       scanf("%s",user_file_name);
   FILE_LOAD(user_file_name);
       doubleLISTDisplay();
break;
}
else
{
doubleLISTDisplay();
}
}
       break;
   case 6:
       store("sample.txt");
       break;
   default:
break;
  
}
   }
return 0;
}

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