Answered step by step
Verified Expert Solution
Link Copied!

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 15% if the bill value is between 50 and300. If the value is different, the tip is 20%.Your tasks:Calculate the tip, depending on the bill value. Create a variable called 'tip' forthis. It's not allowed to use an if/else statement (If it's easier for you, you canstart with an if/else 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 value(bill + tip). Example: The bill was 275, the tip was 41.25, and the total value316.25Write 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 100And 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 1: Test for bill values 275,40 and 430Data 2: 125,555 and 44Hints:To calculate 20% of a value, simply multiply it by 20/100=0.2Value X is between 50 and 300, if it's >=50 && <=300Remember 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

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

Automating Access Databases With Macros

Authors: Fish Davis

1st Edition

1797816349, 978-1797816340

More Books

Students also viewed these Databases questions