Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Steven wants to build a very simple tip calculator for whenever he goes eating in arestaurant. In his country, it's usual to tip 1 5
Steven wants to build a very simple tip calculator for whenever he goes eating in arestaurant. In his country, it's usual to tip if the bill value is between and If the value is different, the tip is Your tasks:Calculate the tip, depending on the bill value. Create a variable called 'tip' forthis. It's not allowed to use an ifelse statement If it's easier for you, you canstart with an ifelse statement, and then try to convert it to a ternaryoperator!Print a string to the console containing the bill value, the tip, and the final valuebill tip Example: The bill was the tip was and the total valueWrite a function 'calcTip' that takes any bill value as an input and returnsthe corresponding tip, calculated based on the rules above you can check outthe code from first tip calculator challenge if you need to Use the functiontype you like the most. Test the function using a bill value of And now let's use arrays! So create an array 'bills' containing the test databelowCreate an array 'tips' containing the tip value for each bill, calculated fromthe function you created beforeCreate an array 'total' containing the total values, so the bill tipTest data:Data : Test for bill values and Data : and Hints:To calculate of a value, simply multiply it by Value X is between and if it's && Remember that an array needs a value in each position, and that value canactually be the returned value of a function! So you can just call a function as arrayvalues so don't store the tip values in separate variables first, but right in the newarray
Step 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