uswhovian

Mar 9th, 2013, 06:01 AM

I'm having trouble with a homework assignment. I'll post the broad objective of it below so you understand what the end result should be. I understand how to use if loops to compare numeric values and tell the user if a number is greater lesser than or equal to another. I understand the basic concepts of while

loops and how to set parameters on how many times they run. Yet I have spent hours trying to figure out how I can compare two user values within a loop. My only thought of how to perhaps accomplish this is to get user input twice during the while loop(meaning I would only loop5 times instead of 10) yet I don't know if this will work or if this is the best way to tackle the problem. It only needs to be written in pseudocode at the moment which helps. But i am just at a loss of how to define and compare user inputted values that are constantly changing within a loop. I've attached a picture of the assignment objective, if my question does not make sense out of context. I would appreciate any help with this aspect of my assignment. I am almost at my wits end! Once I understand this I can easily write the pseduocode and draw the flowchart by myself. Yet I am at a standstill without knowing how to define the variables in this particular situation.

In this assignment, you will write an algorithm that asks the user for 10 different numbers. Aﬁer

each number, you should print whether this number is bigger than, smaller than, or the same as

the one that came right before it. (Note that you won’t print anything after the ﬁrst number, as

nothing came before it.) Below is an example. I have put in BLACK the information that your

algorithm should print, and in RED information that the user is providing. (The red is just the parts that says x is bigger/smaller than y)

Enter numberi 14

Enter numberi 20

20 is bigger than 14

Enter numberi 5

5 is smaller than 20

Enter numberi 5

5 is the same as 5

Enter numberi 10

10 is bigger than 5

Enter numberi -100

-100 is smaller than 10

Enter numberi 0

0 is bigger than -100

Enter numberi 0

0 is the same as 0

Enter numberi 57

57 is bigger than 0

Enter numberi 25

25 is smaller than 57

You should type your algorithm Your solution should include:

0 The steps to solving the problem (your steps should look similar to the examples in the

Designing Loops lecture notes). You should use a loop to get the 10 numbers from the

students, and you should use appropriate variables for storing the current number entered

by the user and the previous number entered by theuser

Sorry for the weird spelling things I used an OCR translator to get the info in txt form

loops and how to set parameters on how many times they run. Yet I have spent hours trying to figure out how I can compare two user values within a loop. My only thought of how to perhaps accomplish this is to get user input twice during the while loop(meaning I would only loop5 times instead of 10) yet I don't know if this will work or if this is the best way to tackle the problem. It only needs to be written in pseudocode at the moment which helps. But i am just at a loss of how to define and compare user inputted values that are constantly changing within a loop. I've attached a picture of the assignment objective, if my question does not make sense out of context. I would appreciate any help with this aspect of my assignment. I am almost at my wits end! Once I understand this I can easily write the pseduocode and draw the flowchart by myself. Yet I am at a standstill without knowing how to define the variables in this particular situation.

In this assignment, you will write an algorithm that asks the user for 10 different numbers. Aﬁer

each number, you should print whether this number is bigger than, smaller than, or the same as

the one that came right before it. (Note that you won’t print anything after the ﬁrst number, as

nothing came before it.) Below is an example. I have put in BLACK the information that your

algorithm should print, and in RED information that the user is providing. (The red is just the parts that says x is bigger/smaller than y)

Enter numberi 14

Enter numberi 20

20 is bigger than 14

Enter numberi 5

5 is smaller than 20

Enter numberi 5

5 is the same as 5

Enter numberi 10

10 is bigger than 5

Enter numberi -100

-100 is smaller than 10

Enter numberi 0

0 is bigger than -100

Enter numberi 0

0 is the same as 0

Enter numberi 57

57 is bigger than 0

Enter numberi 25

25 is smaller than 57

You should type your algorithm Your solution should include:

0 The steps to solving the problem (your steps should look similar to the examples in the

Designing Loops lecture notes). You should use a loop to get the 10 numbers from the

students, and you should use appropriate variables for storing the current number entered

by the user and the previous number entered by theuser

Sorry for the weird spelling things I used an OCR translator to get the info in txt form