Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

assume that my name is xxx yyy, my id is 44853, and my section is M2 please solve using c language Problem Write a C

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

assume that my name is xxx yyy, my id is 44853, and my section is M2

please solve using c language

Problem Write a C program to keep track of ride frequency of a taxi (number of rides per taxi) for different commuters of an online taxi company. The program design should use main and the below functions. Consider the constant COMMUTERS_SIZE with value equal to 3 and TAXIS_SIZE with value equal to 4. The number of rides for each taxi per commuter must be greater than zero. Nested loops, array index notation and break statement are not allowed to be used in the program. You must use a pointer notation to access the arrays' elements. We consider the following arrays named in the program, as follows: Commuter_IDs: is a 10 array of integer of size COMMUTERS_SIZE that stores the IDs of all commuters. Taxi_IDs: is a 1D array of integer of size TAXIS_SIZE that stores the IDs of taxis. Taxi_Frequency: is a 2D array with size equal to COMMUTERS_SIZE X TAXIS_SIZE that stores the number of rides for each taxi per commuter. The row represents the number of commuters and the column represents the number of taxis. In the below example, the commuter with ID = 44 (Row index =0) has 3 rides with Taxi ID = 21 (Column index = 0), 4 rides with taxi ID = 51 (Column index =3), etc. Freq_Riders: is a 10 array of type character with size equal to COMMUTERS_SIZE that stores the frequent rider type for each commuter. 'D' for Diamond, 'G' for Gold, or 'P' for Platinum. Taxi_IDS 21 31 41 51 Commuter_IDs Freq_Riders 0 0 3 8 15 Taxi_Frequency 1 2 3 4 8 8 15 15 COW 3 4 8 15 00 P 1 2 44 G 55 66 D Problem 1. Define a void function FUNCTION1 that takes a 10 array of integer arrA and the size of the array N as formal parameters. The array arra represents the number of rides for N taxis per commuter. The function should prompt the user to fill the array arrA with number of rides until user enters EOF. If the user enters EOF before the end of array, the function should stop reading and assign -25 to all elements of the array arr. For example, if the user enters successfully one or two values from TAXIS_SIZE values terminated by EOF, the program should assign -25 to all elements of the array and stop reading from the standard input. Note that If the value of your AUM ID is less than 40000, you should use a do while loop in this function. If the value of your AUM ID is from 40001 to 50000, you should use a for loop. If the value of your AUM ID is greater than 50000, you should use a while loop in this function. For example, student with ID equal 42357 will use a for loop. (20 points) 2. Define a non-void function FUNCTION2 that takes a 1D array arrA as formal parameter. The array arrA represents the number of rides for each taxi per commuter. The function calculates and returns the average number of rides. If the value of your AUM ID is less than 40000, you should use a while loop in this function. If the value of your AUM ID is from 40001 to 50000, you should use a do while loop. If the value of your AUM ID is greater than 50000, you should use a for loop in this function. For example, student with ID equal 42357 will use a do while loop. (20 points) 3. Define a non-void function named FUNCTION3 that takes the sum of the rides Total_Rides as formal parameter and by using a switch statement, returns the frequent rider value according to the following table. Note that you cannot use if statement in this function. (15 s points) Total_Rides Frequent Rider =20 and =40 D 4. Define a void function FUNCTION4 that takes two 1D arrays, Commuter_IDs of size COMMUTERS_SIZE and Freq_Riders of size COMMUTERS_SIZE as formal parameters. The function then prints the frequent rider ranking for each commuter, as shown in sample output below. (20 points) Frequent Rider D G Frequent Rider Ranking Diamond Gold Platinum P 5. Write a main function to do the following by using the above functions: (25 points) Declare and initialize the array Freq_Riders with 'E' by using a loop. The value 'E' means that there are no valid data yet. Declare and initialize the arrays Commuter_IDs, Taxi_IDs, and Taxi_frequency with the value -1 times the value of your student ID (-1* yourStudentID). For example, if the student ID is 42357, then initialize the arrays with - 42357. The negative value means that there are no valid data yet. Prompt user to initialize the arrays Commuter_IDs and Taxi_IDs. Note that when the user enters -33, the main function should stop reading from the current array and assign -25 to the remaining elements of the array. Prompts user to initialize the array Taxi_Frequency by calling FUNCTION1 for every row in the 2D array. If user enters EOF, the main function should fill the rest of elements of the array with -25. Call FUNCTION2 for every row in the 2D array and print the average rides returned as shown in the sample output. Call FUNCTION3 and FUNCTION4 to find out and print the frequent rider ranking for each commuter. The main function should run successfully with different scenarios. The sample output should contain your name, your CS 159 section number and your ID as shown below. SAMPLE OUTPUT: Enter IDs of 3 commuters: 44 55 66 Enter IDs of 4 Taxis: 21 31 41 51 Enter the number of rides for each commuter Commuter with ID = 44 : Enter positive value 1: 3 Enter positive value 2: 3 Enter positive value 3: 4 Enter positive value 4: 4 Commuter with ID = 55: Enter positive value 1: 8 Enter positive value 2: 8 Enter positive value 3: 8 Enter positive value 4: 8 Commuter with ID = 66 : Enter positive value 1: 15 Enter positive value 2: 15 Enter positive value 3: 15 Enter positive value 4: 15 -----Average Rides Details ---------- Commuter ID Average Rides 44 3.50 55 8.ee 66 15.ee =======Frequent Rider Details======= Commuter ID Frequent Rider Platinum Gold 66 Diamond =========== ================== 44 55 ==== ======= *** ********STUDENT DETAILS***** Student xx YY Section 01 ID = 1234 - Semester SP 2020 Press any key to continue

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Probabilistic Databases

Authors: Dan Suciu, Dan Olteanu, Christopher Re, Christoph Koch

1st Edition

3031007514, 978-3031007514

More Books

Students also viewed these Databases questions

Question

c. What groups were least represented? Why do you think this is so?

Answered: 1 week ago