Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please Solve using MATLAB . To recieve a thumbs up DO NOT USE CONDITIONAL STATEMENT(such as if, else, elseif) and ITERATIONS (loops) on the solution!!
Please Solve using MATLAB. To recieve a thumbs up DO NOT USE CONDITIONAL STATEMENT(such as if, else, elseif) and ITERATIONS (loops) on the solution!!
Function Name: coinCounter Inputs: 1. (double) an N x 4 array containing varying amounts of pennies, nickels, dimes, and quarters in each column 2. (char) a 1x4 char vector detailing the type of coin in each of the columns Outputs: 1. (double) a 5 x N array containing the coin amounts from the original array as well as each employee's total earnings in tips 2. (char) a sentence indicating the highest paid employee in tips and how much they earned for that given day Topics: (array masking). (transpose), (array manipulation), (sorting), (sprint) Background: It is the end of the day after a long shift bussing tables at Rays NY Pizza in Tech Square. You and your coworkers noticed that a ton of Georgia Tech students have been tipping in coins recently, so you decide to put your heads together and calculate who earned the most in tips that night. Everyone split their own coins into different piles of the types of coins they earned and counted how many of each type they had. To make it easier, you decide to use your MATLAB skills to calculate the amount each employee earned. Function Description: Given an N x 4 array (input 1) where each row of the array represents a different employee and each column of the array represents a certain type of coin, determine how much money in tips each of the employees made for a given shift. The values in the array represent the number of each type of coin they received. In the 1 x 4 char vector (input 2), 'p' represents pennies ($0.01), 'n' represents nickels ($0.05), 'd' represents dimes ($0.10), and 'q' represents quarters ($0.25). The order of the char vector represents the type of coin (denoted by the letters 'p', 'n', 'd', and 'q') and its corresponding column (based on its index) in the larger array. For example, the string 'pndq' would mean pennies are in the first column, nickels in the second, dimes in the third, and quarters in the fourth. Calculate each employees' earnings in tips and append a column to the right of the original array containing their corresponding totals. Next, sort the entire array based on each employee's total amount of tips in descending order (the highest paid employee would be the first row, lowest paid employee would be the last). Finally, flip the rows and columns of the array, such that the tip totals are now found in the last row of the array and the employees and the corresponding number of coins they each have are represented by each column, and round all values to the second decimal place. Store the new rounded array in the first output. Finally, output the following statement: Employee numberStep by Step Solution
There are 3 Steps involved in it
Step: 1
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