Jason typically uses the Internet to buy various items. If the total cost of the items ordered, at one time, is $200 or more, then the shipping and handling is free; otherwise, the shipping and handling is $10 per item. Design an algorithm that prompts Jason to enter the number of items ordered and the price of each item. The algorithm then outputs the total billing amount. Your algorithm must use a loop (repetition structure) to get the price of each item. (For simplicity, you may assume that Jason orders no more than five items at a time.)
Include: IPO Chart
Test Plan
Pseudocode Algorithm
Expert Answer
n = input(“enter total number of items”)
sum = 0 #Sum contains the sum of the prices of n items
while n>0
do
x=input(“Enter price of item:”)
sum=sum+x
done
if(sum>=200)
return sum #we are returning sum if its is greater than 200
else
return sum+(10*n) #else we are charging 10$ per item as shipping charge
Equations:
x = sum_{i=1}^{n} price(i) forall x>=200
x = sum_{i=1}^{n} price(i*10) forall x<200
Example Data:
n=5
item1 = 10
item2 = 25
item3 = 15
item4 = 35
item5 = 45
sum = 10+25+15+35+45 = 130
total_billing = 130 + 10*5 = 180
n=7
item1 = 24
item2 = 36
item3 = 52
item4 = 28
item5 = 30
item6 = 70
item7 = 20
sum = 260
total_billing = 260
IPO Chart:
Structured Chart: