Answered step by step
Verified Expert Solution
Link Copied!

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!!

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedPlease 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 number was the highest paid and made $ in tips today.' Where the original employee row corresponds to the row in the original array (prior to sorting) where the highest-paid employee was found and amount corresponds to the amount in tips they made. Example: coinArr: [5 3 8 2; 6 3 2 0; 9] 4 2 11 coinorder= 'dqpn' [tipArr, sentence] = coinCounter (coinArr, coinorder) tipArr 5 3 [4 2 11 9 1.46 6; 3; 2; 8 2 0; 1.37 ] 1.43 'Employee number 3 was the highest paid and made sentence $1.46 in tips today.' Note: the highlighted row/column denotes employee #3 Notes: The coin array will contain only positive integer values The only chars that will be found in the second input are 'p', 'n', 'q', and 'd', appearing exactly as given above and occurring exactly one time each The coins can be given in any order When displaying your output sentence, ensure the dollar amount only displays two values after the decimal (ex. $5.98 rather than $5.9800) Be sure to round the final array as stated above, as to not cause a floating point error (slight rounding inaccuracies with decimals can cause the entire output to be considered incorrect) 0 Hints: Remember conditionals and iteration are banned Think of a way you can do this problem without using conditionals. You are guaranteed to only have 4 types of coins and you know how much each coin is worth. Try using sprintf with %f

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

Advanced Database Systems For Integration Of Media And User Environments 98

Authors: Yahiko Kambayashi, Akifumi Makinouchi, Shunsuke Uemura, Katsumi Tanaka, Yoshifumi Masunaga

1st Edition

9810234368, 978-9810234362

More Books

Students also viewed these Databases questions