Program Design and Algorithym

Kemper

New member
Joined
Sep 8, 2008
Messages
2
Not sure exactly where this ties into.

But I have read my book 4 times and still cannot figure out how to solve this equation.

The question is You require an algorithm that will receive an integer from the screen, add 5 to it, double it, subtract 7 from it, and display the final number on the screen.

I need help finding the Input, Processing and the Output. Also the algorithym.

Any help is greatly appreciated
 
It looks to me like they gave you the algorithm:

... add 5 to it, double it, subtract 7 from it ...

Your teacher is sloppy if they think that each pronoun in the given instruction is intended to reference the preceeding value ... anyway, I think I understand what this algorithm is supposed to accomplish (eg: if the input is 10, then the output is 23).

You need to pick a symbol to represent the value that is "received from the screen". In other words, assign the value from the screen to a variable name, like X.

Is this exercise from a math class or a computer-programming class?

I'm not sure what steps involve receiving the input.

I'm not sure what steps involve displaying the output.

But processing the calculations part is simply a function of carrying out the arithmetic operations on X.

EG:

Receive integer from screen
Reduce it by 50%
Increase the result by 200
Subtract 10 times the original value from this last result
Display final result on screen

Here's one possibility.

(1) Steps to prompt user to enter number (whatever they are ...)
(2) Assign number from screen to X
(3) Assign (0.5X + 200) - 10X to Y
(4) Steps to display Y on screen (whatever they are ...)

Is this example clear?

Cheers,

~ Mark :)
 
The class is supposed to be a "Simple Program Design" :lol: class entry level at College

Thanks for the response.

I pretty much have came up with

Input - Interger 1

Processing - Prompt for integer1, get intger1, calculate sum, product, difference, display intger1

Output - final_number

Algorithym

1-prompt for int.1
2-get integer 1
3- sum = int.1 + 5
4-product = int.1 *2
5-difference = int.1 - 7
6-display sum, product, difference
END

Just not sure thats right :(
 
Kemper said:
The class is supposed to be a "Simple Program Design" :lol: class entry level at College

If you continue on to complex program design, then you won't be laughing ...

I enjoy writing computer programs; it's a challenge to figure out how to instruct a machine (that knows absolutely nothing about anything) to give you exactly what you want!

Okay, I guess your teacher is not sloppy. The goal actually is to display a distinct sum, product, and difference.

Kemper said:
1-prompt for int.1
2-get integer 1
3- sum = int.1 + 5
4-product = int.1 *2
5-difference = int.1 - 7
6-display sum, product, difference

I will "test" your program.

(1) I see a prompt on the screen instructing me to enter an integer
(2) I enter 44, so your program assigns 44 to variable integer 1
(3) Since variable int1 does not exist, the program crashes at this point after trying to add 5 to garbage

(You may not have intended to change the variable name after step 2, but the dumb machine is not capable of understanding this, so BE CONSISTENT.)

After changing the variable name in step 2 from Integer 1 to int1, we start over.

(1) I see a prompt on the screen instructing me to enter an integer
(2) I enter 44, so your program assigns 44 to variable int1
(3) Your program assigns 49 to variable sum
(4) Your program assigns 88 to variable product
(5) Your program assigns 37 to variable difference
(6) I see 49 88 37 on the screen

Looks like a good algorithm to me.

If you were to continue to write the actual code, then you would need to consider how to format what the end-user sees on the screen -- both the prompting message and the final output.

~ Mark :)
 
Top