UCA08 - Algorithm GAUGE Given three products product1 product2 product3,current prices current price1 current price2 current price3 and old prices(old

# UCA08 - Algorithm GAUGE Given three products product1...

This preview shows page 1 - 3 out of 3 pages.

Algorithm GAUGE . Given three products ( product1, product2, product3 ) ,current prices ( current price1, current price2, current price3 ) and old prices ( old price1, old price2, old price3 ) for each product. Calculate algebraic difference ( alg_diff) and percentage difference (pc_diff ). The product names are Strings and current and old prices are real numbers. [ Step 1 : Get product names and prices ] Read olive oil, gallon of milk, coffee. [ Step 2 : Calculate algebraic difference] Algebraic difference = Current price - Old price [ Step 3 : Calculate percentage difference] Percentage difference =(Current price - Old price) / old price * 100% [ Step 4 : Print the calculation and other information you want to print ] ITEM PURCHASED: <item> PRICE THIS MONTH: \$<current_price> PRICE LAST MONTH: \$<old_price> ALGEBRAIC DIFFERENCE: \$<alg_diff> PERCENTAGE DIFFERENCE: <pc_diff>% [ Finished ] Exit Step item current_price old_pric e alg_diff pc_diff 1 Olive oil 8.59 8.49 0.10 ? 2

#### You've reached the end of your free preview.

Want to read all 3 pages?

• Spring '14
• \$3.30, \$4.99, \$5.29, \$8.59, \$8.49

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern

Stuck? We have tutors online 24/7 who can help you get unstuck.
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes