Details of this Paper

Input a list of positive numbers, terminated by 0

Description

solution


Question

Programming Assignment# 3 Program #1 (RAPTOR & JAVA) Using RAPTOR for Arrays (Chapter 6) Creating arrays in RAPTOR is a little different from the way the textbook explains them. The textbook uses 0 as the first index of an array. In other words, the first element of an array named VenitItems is VenitItems[0]. The second element is VenitItems[1], the third element is VenitItems [2], and so on. This is the way most programming languages ? like C++ and Java ? create arrays. If you want to fill an array with 5 elements, using a loop, and using the textbook pseudocode, you would set a counter equal to 0 and have the loop go around until the counter reached 4. Count them yourself ? when the counter is 0, that?s the first loop, when the counter is 1, that?s the second loop, when the counter is 2, that?s the third loop, when the counter is 3, that?s the fourth loop, and when the counter is 4, that?s your fifth loop. If you wanted to fill the VenitItems array with the numbers 2, 4, 8, 16, and 32 you would write: Set J = 2 For (K = 0, K<=4, K++) Set VenitItems[K] = J J = J * 2 End For However, RAPTOR arrays begin with index 1. In other words, the first element of an array named RaptorItems is RaptorItems[1]. The second element of this array is RaptorItems[2]. So this changes the way you would write the pseudocode. If you wanted to fill the RaptorItems array with the numbers 2, 4, 8, 16, and 32, you would now write: Set J = 2 For (K = 1, K<=5, K++) Set RaptorItems[K] = J J = J * 2 End For You will have to make changes in the pseudocode you create for textbook exercises if you want your programs to work in RAPTOR. Just be aware of this very important difference!;Programming Assignment# 3 Program #1 Page 2;PROGRAMMING PROBLEM Input a list of positive numbers, terminated by 0, into an array Numbers. Then display the array and the largest and smallest number in it. Creating arrays in RAPTOR is a little different from the way the textbook explains them. The textbook uses 0 as the first index of an array. In other words, the first element of an array named VenitItems is VenitItems[0]. The second element is VenitItems[1], the third element is VenitItems [2], and so on. This is the way most programming languages ? like the JAVA program attached to your homework. Use a For-Next loop to fill an array with 5 elements and set a counter equal to 0 and have the loop go around until the counter reached 4. Count them yourself ? when the counter is 0, that?s the first iteration, when the counter is 1, that?s the second iteration, when the counter is 2, that?s the third iteration, when the counter is 3, that?s the fourth iteration, and when the counter is 4, that?s your fifth iteration. If you wanted to fill the VenitItems array with the numbers 2, 4, 8, 16, and 32 you would write: Set J = 2 For (K = 0, K<=4, K++) Set VenitItems[K] = J J = J * 2 End For However, RAPTOR arrays begin with index 1. In other words, the first element of an array named RaptorItems is RaptorItems[1]. The second element of this array is RaptorItems[2]. So this changes the way you would write the pseudocode. If you wanted to fill the RaptorItems array with the numbers 2, 4, 8, 16, and 32, you would now write: Set J = 2 For (K = 1, K<=5, K++) Set RaptorItems[K] = J J = J * 2 End For You will have to make changes in the Pseudocode you create for textbook exercises if you want your programs to work in RAPTOR. Just be aware of this very important difference!;Programming Assignment# 3 Program #1 Page 3;Input a list of positive numbers, terminated by 0, into an array Numbers. Then display the array and the largest and smallest number in it.

 

Paper#69998 | Written in 18-Jul-2015

Price : $27
SiteLock