79.8k views
5 votes
// This program is supposed to display every fifth year // starting with 2017; that is, 2017, 2022, 2027, 2032, // and so on, for 30 years. start Declarations num year num START_YEAR = 2017 num FACTOR = 5 num END_YEAR = 30 year = START_YEAR while year <= END_YEAR output year endif stop 1. What problems do you see in this logic? 2. Show corrected pseudocode to fix the problems. 3. Is there another way the code can be corrected and still have the same outcome? If so, please describe. 4. Implement your pseudocode in either Raptor or VBA. (submit this file) 5. Does it work? You must test your code before submitting and indicate if the program functions according to the assignment description. Explain.

User Chaoley
by
6.1k points

1 Answer

4 votes

Answer:

Explanation:

1. The problems in the above pseudocode include (but not limited to) the following

1. The end year is not properly represented.

2. Though, the factor of 5 is declared, it's not implemented as increment in the pseudocode

3. Incorrect use of control structures. (While ...... And .......Endif)

2.

Start

Start_Year = 2017

Kount = 1

While Kount <= 30

Display Start_Year

Start_Year = Start_Year + 5

Kount = Kount + 1

End While

Stop

3. Yes, by doing the following

* Apply increment of 5 to start year within the whole loop, where necessary

* Use matching control structures

While statement ends with End While (not end if, as it is in the question)

4. Using VBA

Dim Start_Year: Start_Year = 2017 ' Declare and initialise year to 2017

Dim Counter: Counter = 1 ' Declare and Initialise Counter to 1

While Count <= 30 ' Test Value of Counter; to check if the desired number of year has gotten to 30. While the condition remains value, the following code will be executed.

msgbox Start_Year ' Display the value of start year

Start_Year = Start_Year + 5 'Increase value of start year by a factor of 5

Counter = Counter + 1 'Increment Counter

Wend

5. Yes

User James Lee Baker
by
5.8k points