Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question
write a code in C++
You work for a streaming analytics company and have been tasked with writing a
Code a modular program that uses parallel arrays to store views, likes, and like percentages for a series of videos.
The program must do the following:
- The program must first ask the user for the number of videos that will be selected from YouTube. This must be done using a function that is called.
- For each video, the program must use random numbers to generate the number of views, likes, and the like percentage and store each value in a series of parallel arrays. These arrays must NOT be declared globally. These arrays also must be populated using a loop that calls a series of functions to generate the views, likes, and like percentage.
- The following arrays must be declared:
- views[] - an array of type long to hold the randomly generated views each YouTube video gets
- likes[] - an array of type long to hold the randomly generated likes each YouTube video gets (based on the number of views)
- likePercentages[] - an array of type double to hold the calculated percentages of likes of each video (ratio of likes to views)
- The following arrays must be declared:
- Once all of the arrays are populated, the program must display the stats for all of the videos. This includes displaying the number of views, likes, and the like percentage for each video. This must be done by calling a function that accepts each of the parallel arrays as well as the number of videos entered in step 1.
- Once the stats for the videos are displayed, the program must calculate and display the following:
- The video with the most views by calling a function that accepts an array that contains the array of views and the number of videos entered in step 1.
- The video with the least views by calling a function that accepts an array that contains the array of views and the number of videos entered in step 1.
- The video with the most likes by calling a function that accepts an array that contains the array of likes and the number of videos entered in step 1.
- The video with the least likes by calling a function that accepts an array that contains the array of likes and the number of videos entered in step 1.
- getNumVideos() - function must allow the user to specify the number of YouTube videos to be selected. Validate the user input so that the user must enter between 1 and 9 videos. If the user enters an invalid number of videos, they must be given an unlimited amount of chances to enter a valid number of YouTube videos. The function must return the validated number of YouTube videos.
- generateViews() - function will generate a random number of views for each video. Many videos on YouTube go viral, with very high view counts, so generate and return an amount of views up to 100,000,000,000. Note: use the long data type to return the number of views and store in the appropriate array.
- generateLikes() - Likes are generated based on the number of views generated on a YouTube video. Function must accept the views generated from the YouTube video and generate and return an amount of likes based on the the number of views the video has generated. Note: use the long data type to return the number of likes and store in the appropriate array.
- calculateLikePct() - Function must accept the views and the likes generated from the YouTube video and calculate the like percentage for each video using the following formula: like percentage = likes / views. Calculate and return the like percentage and store in the appropriate array Note: views and likes should be long data type, you will need to use type casting to convert them to a double to ensure proper calculation.
- displayStats() - Function must accept the parallel arrays that contain the views, likes, and percentages of likes as well as the number of videos and display the video number along with stats for each video formatted with proper spacing on separate lines to match the sample output. Format the percentages of the likes to show numbers with 2 decimal places.
- maxViews() - Function must accept the array that contains the number of views as well as the number of videos entered and display the video that has the most views.
- minViews() - Function must accept the array that contains the number of views as well as the number of videos entered and display the video that has the least views.
- maxLikes() - Function must accept the array that contains the number of likes as well as the number of videos entered and display the video that has the most likes.
- minLikes() - Function must accept the array that contains the number of likes as well as the number of videos entered and display the video that has the least likes.
Other Notes:
Program Output and Prompts MUST MATCH the formatting of the sample runs EXACTLY.
output below
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 4 steps with 4 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- C++ Use 2 D arrays String and float Make simplearrow_forwardC languagearrow_forwardCreate Array of Random Dates In this task you are required to write a function that will generate a column array (a variable called dates) containing N random dates. N is an integer (whole number) entered by the user and will indicate to the function how many random dates the user requires. The dates array will be structured as follows: • The array shall have two columns; column 1 will contain numbers indicating the day of each month (1-31) and column 2 will contain numbers indicating the month (Jan 1, Feb=2, Mar = 3.... Dec = 12). . Each day must be randomly generated (using the randi() function) taking into account the maximum number of days in each month (i.e. Jan, Mar, May, Jul, Aug. Oct and Dec have 31 days, Apr. Jun, Sep and Nov have 30 days and Feb will have 28 days). You must use an if-elseif-else statement to decide this. • We are assuming no leap years (e. February can only have days between 1-28). For example, the output from calling the function: output = dategen (3) could…arrow_forward
- WRITE A PROGRAM IN C++ You work for an loan analytics organization have been tasked with writing a program that simulates an analysis of loan applications. Code a modular program that uses parallel arrays to store loan application credit scores (values generated between 300 and 900), score ratings (poor, fair, good, very good, or exceptional based on credit score) and loan status (approved or declined applications based on credit score). The program must do the following: The program must first ask the user for the number of loan applications that will be in the simulation. This must be done by calling the getNumLoanApplications() function (definition below). After the input of the number of accounts, the program must use loops and random numbers to generate the credit score, score rating, and application result for each loan application in parallel arrays. These arrays must not be declared globally (major error). The following arrays must be declared and populated: creditScores[]…arrow_forwardProgramming in Carrow_forwardThis is warning you, don't use any AI platform to generate answer.arrow_forward
- In C programming: Write a function printAllCourses() which receives an array of course pointers and the array’s size, then prints all courses in the array by calling printCourseRow()arrow_forwardplaese code in python You are tasked with creating a square grid of values in which each value only appears once in each column and once in each row (think like a Sudoku). Write a function called grid that inputs a list and outputs a square grid of values of that list in which each value only appears once in each column and once in each row. Specifically, one in which each row is the one above it shifted by one item. Your answer should be in the form of a list of lists, where each sub-list is a row of the square. For example: grid([1, 2, 3, 4]) -> [[1, 2, 3, 4], [4, 1, 2, 3], [3, 4, 1, 2], [2, 3, 4, 1]]arrow_forwardc++ code Screenshot and code is mustarrow_forward
- Describe how to pass an array as a parameter to a function.arrow_forwardProgramming C++ Instructions Redo Programming Exercise 14 by first sorting the array before determining the array elements that are the sum of two other elements. Use a selection sort algorithm, to sort the array. Instructions and code have been included. Exercise 14 Write a program that prompts the user to enter 50 integers and stores them in an array. The program then determines and outputs which numbers in the array are sum of two other array elements. If an array element is the sum of two other array elements, then for this array element, the program should output all such pairs. Thank you for the help! This is the code so far. /* 10 17 23 65 34 6 18 27 35 110 75 25 100 24 19 67 45 88 70 96 41 36 72 150 125 25 77 200 90 166 139 55 31 8 29 119 126 137 34 62 135 121 108 197 45 35 24 1 16 43 */ #include <iostream> using namespace std; const int LIST_SIZE = 50; int main() { int list[50]; cout << "Enter " << LIST_SIZE << " integers: ";…arrow_forwarduse c++ Programming language Write a program that creates a two dimensional array initialized with test data. Use any data type you wish . The program should have following functions: .getAverage: This function should accept a two dimensional array as its argument and return the average of each row (each student have their average) and each column (class test average) all the values in the array. .getRowTotal: This function should accept a two dimensional array as its first argument and an integer as its second argument. The second argument should be the subscript of a row in the array. The function should return the total of the values in the specified row. .getColumnTotal: This function should accept a two dimensional array as its first argument and an integer as its second argument. The second argument should be the subscript of a column in the array. The function should return the total of the values in the specified column. .getHighestInRow: This function should accept a two…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education