Instruction Write a C program that prompts the user to desig

Instruction: Write a C program that prompts the user to design and implement a Music Library. The Library should be composed of Albums and Songs. Use structures and typedef to declare the albums and songs. Enum should be used for declaring the ratings of the song and the genre Album should contain the following fields: Album\'s name Album ID (e.g. 1234) Genre (Pop, Rock, Classic, etc.) Artist/Band (Specific name) Year Published (e.g. 2010) Price (e g. $8 99) Songs (List of songs the album contains) Rating (Must be one, two...five stars) The songs should contain the following fields: Song name Song ID (e.g. 1234) Genre (Pop, Rock, Classic, etc.) Artist (Specific name) Year Published (e.g. 2010) Price (e.g. $8 99) Rating (Must be one, two...five stars) Write a main() function where the functions are called Menu function should be written to allow the user to select options listed. Create and add an album to the Database. Remove an album from the database. Create and add a song to the database. Delete a song. Search for an album. Search for a song. And write the function to create a song with all its corresponding fields. Rubric:

Solution


// Include the standard input/output header file and declare all constants
#include<stdio.h>
#include<string.h>
#include<windows.h>
#define FILENAME \"music.txt\"
#define N 50

int main(void)
{
    int k=0, length, speed[N];
    // Frequency of notes
    double A=440.00, B=493.88, C=523.25, D=587.33, E=659.26, F=698.46, G=783.99;
    double a=466.16, c=554.37, d=622.25, f=739.99, g=830.61;
    HANDLE hConsole;
    char *myString;
    FILE *music;

     
    hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
    printf(\"The program will play music in one octive from A to G.\ To play a\"
        \" note use the upper case letter. For a sharp use the lower case\"
        \" letter. If you would like a small break use the \'space\'.\ You must \"
        \"create the entire song in a txt file called \'music.txt\'\ \");
     
    music = fopen(\"music.txt\", \"r\");
     
    // Checking to make sure the file is there
    if(music==NULL)
        printf(\"file not found\ \");
         
    else
    {
        
        // Scanning the file for the music notes and length of note
        while(fscanf(music, \"%c%d\ \", &myString[k], &speed[k])==2)
        {
            printf(\"%c    %i\ \", myString[k], speed[k]);
            k++;
        }
        // Checking length of string   
        length = strlen(myString);
         
        // Setting the length of each note into miliseconds
        for(k=0;k<length;k++)
        {
            if(speed[k]==1)
                speed[k]=100;
            if(speed[k]==2)
                speed[k]=200;
            if(speed[k]==3)
                speed[k]=300;
            if(speed[k]==4)
                speed[k]=400;
        }
         
        // Playing the music
        for(k=0;k<length;k++)
        {
            if(myString[k]==\'a\')
                Beep(a,speed[k]);
            if(myString[k]==\'c\')
                Beep(c,speed[k]);
            if(myString[k]==\'d\')
                Beep(d,speed[k]);
            if(myString[k]==\'f\')
                Beep(f,speed[k]);
            if(myString[k]==\'g\')
                Beep(g,speed[k]);
            if(myString[k]==\'A\')
                Beep(A,speed[k]);
            if(myString[k]==\'B\')
                Beep(B,speed[k]);
            if(myString[k]==\'C\')
                Beep(C,speed[k]);
            if(myString[k]==\'D\')
                Beep(D,speed[k]);
            if(myString[k]==\'E\')
                Beep(E,speed[k]);
            if(myString[k]==\'F\')
                Beep(F,speed[k]);
            if(myString[k]==\'G\')
                Beep(G,speed[k]);
            if(myString[k]==\' \')
                sleep(speed[k]);
        }
    // Closing the open file
    fclose(music);
    }
     
    system(\"pause\");
    return (0);
}

 Instruction: Write a C program that prompts the user to design and implement a Music Library. The Library should be composed of Albums and Songs. Use structure
 Instruction: Write a C program that prompts the user to design and implement a Music Library. The Library should be composed of Albums and Songs. Use structure

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site