Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Algorithm writing 2 Instructions: Algorithms are a generic way of describing a s

ID: 3888025 • Letter: A

Question

Algorithm writing 2

Instructions:
Algorithms are a generic way of describing a solution to a computational problem without use of any specific programming language syntax. It cannot be executed on a real computer, but it can model and resemble real programming code. Natural language is used whenever details are unimportant or distracting.

Your algorithm:

Must be unambiguous (exact)…are the steps numbered? …do we always know where to go next or are we left hanging?

Must be correct (solves the problem)…are the ‘requirements’ being met?

Must come to an end (terminate)…how do we know when to end this?

Must be general (for all cases)….can we input any data & still solve the problem?

Must be at the right level of detail….will a computer (in general) understand what we are asking it to do?

Requirements --> You have a store that sells lemons and oranges. Oranges are $.30 each and lemons are $.15 each. Your solution to this problem should get from the user the numbers of oranges and lemons he/she wants and outputs the total amount of money they owe you.

Explanation / Answer

Answer:

Whatever requirements you mentioned in question, all those requirements met with my algorithm.

Please find below my Algorithm.

Step 1: Start

Step 2: Declare variables orangeCost, lemonCost, noOfOranges, noOfLemons and totalAmount .

Step 3: Initialize orangeCost=.30 and lemonCost=.15

Step 4: Read variables noOfOranges, noOfLemons

Step 5: Compute totalAmount = noOfOranges*orangeCost + noOfLemons*lemonCost

Step 6: Display totalAmount

Step 7: Stop

Please let me know if you have any doubts

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote