Algorithm Assignment:

For each of the problems below I want you to set up a table that will show the input, processing and output.  Then I want you to test your algorithm with test data you develop.  See if the answer is correct. 

For example, lets say I want to input two numbers and add them together and display the total.  The answer that I am looking for would look like this.

Input

Processing

Output

number1

number2

get first number and store as number1

get second number and store as number2

total = number1 + number2

total

The processing steps must be in order and steps cannot be skipped.  We are writing these steps so that we could eventually program a computer to follow the steps and create the output. The table below shows a test of the algorithm.

Input

Processing

Output

49

24

number1 = 49

number2 = 24

total =  49 + 24

73

 

 

Problem #1:  Take in the height and width and depth of a box and determine its volume.

 

Problem #2:  Take in the customer’s food charges and their beverage charges. Add them together to get the total before tax.  Calculate the tax (use 5%) and give the price after taxes. Now calculate the tip (you are tipping at 15%) and add that to the total.  Display three outputs: Before taxes, including taxes, including taxes and tip.

 

Problem #3: Take in three items that a customer purchased. Take in a coupon code a well.

Discounts only apply to purchases over 100 dollars. If the coupon code is 10, give the customer 10 dollars off the purchase. If the coupon code is a 5, give the customer 5 dollars off the purchase.

Calculate the tax at 4% and tell the customer how much they owe originally, after discounts are taken and after taxes are added.

 

Problem #4:  Employees are paid on a project basis.  Lets say an employee works on 4 projects during the week and there is a fifth project classified as other.  Take in the hours for all 5 projects. . Take in the contracted hours the employee worked. Take in the pay per hour.  Take in the pay per hour for overtime hours.

You need to get the total for the hours worked on the five projects.

 If the total of the 5 projects is greater than the contracted hours, the employee is entitled to be paid at the overtime rate for the hours over the contracted hours.

Determine the employee’s pay.

When you test this, be sure you test for an employee that will get overtime and test again for an employee that will not get overtime.