Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Preamble Using simple English sentences ( in the style of the example algorithms presented in class ) , write algorithms for each of the following

Preamble
Using simple English sentences (in the style of the example algorithms presented in class), write algorithms for each of the following problems. Be sure to describe your algorithms accurately and explicitly. Assume that the person who reads your instructions does not understand the problem.
Type your algorithms into a word processor with your name and student number at the top. Use good indentation and spacing for readability.
Finally, remember the basic computer design rules and do not write code in any programming language!
Problem Statement
The problems:
A. Many jam recipes measure the amount of fruit and white sugar required in cups, for example. Other recipes use kilograms of fruit and white sugar, for example. Give an algorithm that will determine which recipe uses more white sugar. (Note: Pay attention to what type of sugar your recipe uses!)
B. Suppose you have a calculator with no square root button, but you really need to calculate x2. What do you do? You guess! (Carefully, of course.)
For example, suppose you need to calculate 272. You would first guess that 1 is your answer. Definitely not close enough because 12 is not close to 27. A second better guess is 1+2712, which is 14. Still not close enough because 142 is not close to 27. A third better guess is 14+27142=7.9642dots, which is still not close enough, but is closer! Keep going until your guess is accurate enough.
If a particular guess, n, is not close enough to being an accurate square root of a number x, we can produce a new and better guess by calculating n+xn2. For your algorithm, "accurate enough" means accurate to three decimal places.
C. Write an algorithm to determine whether it is cheaper for your instructor to purchase a Translink monthly pass for the month of February or to use Stored Value instead. (Assume your instructor arrives immediately before his first class at Langara and returns to New Westminster immediately after his last class each day.) Think about how you would generalize your algorithm so it will work for other instructors and other schedules and situations, too.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Essential SQLAlchemy Mapping Python To Databases

Authors: Myers, Jason Myers

2nd Edition

1491916567, 9781491916568

More Books

Students also viewed these Databases questions