Question: C PROGRAMMING CODE ! Part 2 Write the C code necessary for calculating the tip on a bill You must have a single variable that

C PROGRAMMING CODE !C PROGRAMMING CODE ! Part 2 Write the C code necessary for

Part 2 Write the C code necessary for calculating the tip on a bill You must have a single variable that holds the bill amount. When this value is changed, all subsequent calculations remain correct calculate the tip for rates of 10%, 15%, and 20%, and report (output) each tip amount along with the bill+tip total. For example, using an amount of $100.00 for the bill: For a bill of $100.00 a 10% tip is $10.00 giving a total of $110.00 a 15% tip is $15.00 giving a total of $115.00 a 20% tip is $20.00 giving a total of $120.00 For example, using an amount of $10.50 for the bill: For a bill of $10.50 a 10% tip is $1.05 giving a total of $11.55 a 15% tip is $1.58 giving a total of $12.08 a 20% tip is $2.10 giving a total of $12.60 If desired, temporarily change the output to 16 digits of precision to see what is happening. Round the tip results to the nearest penny. This does not mean just print out the answer to 2 decimal places. You actually have to perform the arithmetic to accomplish the rounding (using just the operators that we have used in class). When rounding the "half penny", round up. To prove that you have succeeded, print your dollar amounts to 3 decimal places (instead of the 2 illustrated above). If your output has 2 decimal places, it will be assumed that you did not properly round the values, and you will lose points. Make sure to use an amount for the bill that forces the need for rounding so that the instructor can tell that the code is working properly. For example, a tip of 15% on $10.50 is, without rounding, is $1.575 giving a total of $12.075. with proper rounding the result is a 15% tip is $1.580 giving a total of $12.080

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!