Question
You have been hired by a file hosting streaming service to write a program that will calculate the cost of a user to store and
You have been hired by a file hosting streaming service to write a program that will calculate the cost of a user to store and stream audio files. The streaming platform hosts two types of audio files: MPEG-Layer 3 (MP3) and Waveform Audio (WAV). These files can be streamed in three different sound qualities, where WAV files can also be streamed in Mono or Stereo. Your source code must use menu-driven logic to allow for the user to enter the following audio file information: the file type, the bitrate of sound quality, and the sound type (for WAV files). After entering the audio file information, the user must enter the duration of the file in minutes and seconds. On this streaming service, files have a maximum duration of 180 total minutes per file. Once the file information and the duration of the stream have been entered, the file size must be calculated in Megabytes (MB) based on the file information and duration. For metrics purposes, the cost per minute of the stream as well as the cost per MB of the stream must be calculated. Calculate the total cost of the stream including tax and display a bill for the stream of the file. See the Sample Output. The streaming service tax rate is 7.23%. Use named constants (declared in your program using the 'const double ' naming convention) to hold the cost per minute (bitrate) of each of audio quality types, the base subtotal of the stream (based on duration in total minutes and seconds), and the streaming service tax rate. Use the constants in your calculations and wherever else they are appropriate in your program.
Use the following table to calculate bitrates for streams based on File Types, Sound Type (where applicable) and Sound Quality. Each bitrate must be stored in a named constant in your source file based on the instructions above:
NOTE - MP3 Files on this platform do not have 'Sound Type' attributes, only WAV files.
File Type | Quality | Bitrate |
MP3 | Standard - 160kbps | 1.20 MB per minute |
Premium - 192kbps | 1.44 MB per minute | |
Ultra Quality - 320kbps | 2.40 MB per minute |
WAV | Sound Type | Quality | Bitrate |
Mono | Standard Quality - 16 bit, 44.1 KHz | 5.29 MB per minute | |
Premium Quality - 24 bit, 48 KHz | 8.64 MB per minute | ||
Ultra Quality - 24 bit, 96 KHz | 17.28 MB per minute | ||
Stereo | Standard Quality - 16 bit, 44.1 KHz | 10.58 MB per minute | |
Premium Quality - 24 bit, 48 KHz | 17.28 MB per minute | ||
Ultra Quality - 24 bit, 96 KHz | 34.56 MB per minute |
Use the following table to calculate the subtotal based on the duration of the stream in total minutes and seconds.
NOTE: Each base subtotal must be stored in a named constant per the instructions above.
Stream Length | Base Subtotal |
10 minutes or less | $1.99 |
more than 10 minutes and less than 30 minutes | $5.99 |
more than 30 minutes and less than 60 minutes | $9.99 |
more than 60 minutes | $12.99 |
Project 2 is a continuation of Project 1. For this part of the project, you will add a third menu to control the operation of the program. This menu should give the user the ability to process a single MP3 or WAV file, process multiple randomly generated recording files, or quit the program. For this new menu only, you must validate the user’s menu choice so that only values of A, B, or C are accepted and users have an unlimited number of chances to enter a valid menu choice. Your program must continue to run until the user chooses the “quit” option from your menu.
Steps:
- Add a menu to offer the user a choice of processing a single recording file, processing multiple recording files, or quit the program. This menu must consist of the first outputs displayed when your program begins executing. The menu format should match the one in the Sample Run Video.
- If option A is selected, the program must allow for the user to enter and process the same information for a single audio file from project 1.
- Allow the user to continue making menu choices until they choose the option to quit. Always display the menu before prompting the user for a menu option. Properly handle an invalid menu choice. Your program code must allow the the user to have an unlimited number of chances to enter a valid menu choice.
- Update all previous input validations from Project 1 to allow the user unlimited chances to enter valid information if an invalid input of a menu choice or value is entered. Since this is a level 100 course, cross data type input validation is not required.
- Add functionality to display randomly generated recordings. When the user selects the option to process multiple recording files, file information must be created and displayed for every file generated. The user must be asked to enter the number of recording files they would like to generate, then random values must be used to generate the audio file type (MP3 or WAV), the bitrate quality, and the mono or stereo file type (if a WAV file is generated), and the duration in minutes and seconds (if necessary up to 180 total minutes per recording). Each audio file information display generated should present the recording number, file type (MP3 or WAV), the sound type (Mono or Stereo, if a WAV file is generated), the bitrate quality of the file, the duration of the recording in minutes (and seconds, if necessary), the file size, subtotal, cost per minute of the recording, the cost per MB of the recording, the streaming tax for the file, and the total cost for the file stream. See the Sample Run Video for what each audio file output must contain. The example contains 5 outputs, but your program must be able to process any number of recordings based on the number of recordings the user chooses. Validate the input of the number of recordings so that the user must enter at least 1 recording and no more than 25 recordings. Give the user an unlimited amount of chances to enter the a valid number of recordings. Once all of the information from the recordings has been processed, display the total recordings streamed on the instance of this option being selected, the total MB streamed, the total duration of streams in minutes and seconds, and the total cost of all streams generated. This logic must execute in the event that option B is selected from the main menu.
- If option C is selected from the main menu, the program must quit.
Step by Step Solution
3.52 Rating (152 Votes )
There are 3 Steps involved in it
Step: 1
Python Program to Calculate the Cost of Storing and Streaming Audio Files Python Import necessary libraries import random Define named constants for file types sound types bitrates and streaming tax r...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started