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 4, display 4 lines of lyrics.
Choose a song with at least 10 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 hard-code 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 hmwk1_mweeks.c -o hmwk1_mweeks
cascade:~>./hmwk1_mweeks
Enter an integer: 4
Well, everybody's talking about the bird!
Oom oom oom oom, ooma mow mow
A well a bird
B-b-b aah, aah!
cascade:~>./hmwk1_mweeks
Enter an integer: 4
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 (i.e. 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 0 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. E.g., if the user enters 12, your program should print 12 lines of lyrics. Occassional repeats are OK as long as the lines are chosen at random.
Name your source file 'hmwk1_XX.c' 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 back-up.
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 function/variable names, and consistent indentation.
Make sure to have a back-up of your program before you go on to the next step.
Create a log file, and submit your work to the T.A. :
When you are finally done with your program, and are ready to submit it, do the following steps.
script hmwk1_XX.log
This command starts recording all the things you type and the responses from the system. "hmwk1_XX.log" is just the name of the file it creates. It is a good idea for you to keep backup copies of your program, i.e."hmwk1_XX.c" is obviously the first assignment. Also note that we use ".c" as our file's extension.
cat hmwk1_XX.c
Shows the contents of the file. You may want to include other relevant commands, such as "ls -l", which gives a file list.
gcc hmwk1_XX.c -o hmwk1_XX
Compiles it.
./hmwk1_XX
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 type/system responses. You can now view "hmwk1.log"
Clean up the log file, and call the cleaned-up version hmwk1_XX.txt. Make sure it does not have any extraneous characters, and is a plain text file (no proprietary formats). It should be in a mono-spaced font, though if you saved it as a plain text file, this is not a concern. Submit this and your hmwk1_XX.c 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 blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!