Question: In this assignment, you are to create C program to display song lyrics in a random order. Prompt the user to enter an integer number,
In this assignment, you are to create C program to display song lyrics in a random order. Prompt the user to enter an integer number, then randomly display a line from a song, and repeat this according to the integer. That is if the user enters display lines of lyrics.
Choose a song with at least lines of lyrics, and be sure to include the artist's name, song name, and if applicable album name in comments in your program. You are welcome to choose a song that you like, though keep in mind that we will grade it so if the lyrics contain words that you would not say in front of your parents, you should find another song.
To keep things simple, you can hardcode the lyrics. That is you can put each line of lyrics into its own printf statement. Then randomly choose which printf statement is called. Since the lines are printed at random, it should be different every time.
The lyrics do not have to be accurate. Feel free to use "misheard" song lyrics. For example, many people think Taylor Swift is saying "All the lonely Starbucks lovers" in her "Blank Space" song.
Here's an example of what the output might look like:
cascade:~ gcc hmwkmweeks.c o hmwkmweeks
cascade:~hmwkmweeks
Enter an integer:
Well, everybody's talking about the bird!
Oom oom oom oom, ooma mow mow
A well a bird
Bbb aah, aah!
cascade:~hmwkmweeks
Enter an integer:
Pa pa pa pa pa pa pa pa pa pa pa pa
A well a bird
Surfin' bird
A well a don't you know about the bird?
cascade:~
Each run of the program should give somewhat different output.
Notes:
You will need to turn in a log file showing your program ie with cat Show that it works for several test cases.
You may be asked to meet with your TA to demonstrate your solution.
Click here for a script that shows the contents of several C programs, along with compilation, and example runs. This shows input and output, a for loop, a switch statement, and how you can get a random number.
You should have a return type of "int", and return at the end of the main function.
INPUT: Read an integer from the user.
OUTPUT: Output a prompt for the user to know about the input. Then print a random lyric from a song and repeat this for a total of N times, where N is the number input. Eg if the user enters your program should print lines of lyrics. Occassional repeats are OK as long as the lines are chosen at random.
Name your source file hmwkXXc and store it in your directory on the class computer Snowball Replace XX with whatever corresponds to your account. Note that you will need to change the class name in the file accordingly. Make sure to keep a backup
Turning in your code
Be sure to follow the instructions for turning in a program in the Lab instructions.
As you are aware certain types of assistance are inappropriate in this class. Read the collaboration policy given to you at the beginning of the semester, if you have any questions.
Code documentation.
In any language, good documentation is very important. You can add comments at the end of a line, or above a line. Your program should include comments within the code, not just at the top. These comments will explain what your program is doing. You should have good comments, informative functionvariable names, and consistent indentation.
Make sure to have a backup of your program before you go on to the next step.
Create a log file, and submit your work to the TA :
When you are finally done with your program, and are ready to submit it do the following steps.
script hmwkXXlog
This command starts recording all the things you type and the responses from the system. hmwkXXlog is just the name of the file it creates. It is a good idea for you to keep backup copies of your program, iehmwkXXc is obviously the first assignment. Also note that we use c as our file's extension.
cat hmwkXXc
Shows the contents of the file. You may want to include other relevant commands, such as ls l which gives a file list.
gcc hmwkXXc o hmwkXX
Compiles it
hmwkXX
Runs your program. Be sure to try enough test cases to be sure that it works.
exit
This command ends the recording of the things you typesystem responses. You can now view hmwklog
Clean up the log file, and call the cleanedup version hmwkXXtxt Make sure it does not have any extraneous characters, and is a plain text file no proprietary formats It should be in a monospaced font, though if you saved it as a plain text file, this is not a concern. Submit this and your hmwkXXc file to the grader through the iCollege folder.
Make sure it has all of the relevant information on it such as your name, the source code, the compilation, and runs of your program.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
