Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Pseudocodes has some errors can someone please help determining what/these error

ID: 662784 • Letter: P

Question

Pseudocodes has some errors can someone please help determining what/these errors are thank you

/ Program gives user a 10% raise

start

   Declarations

      num payRate

      num RAISE_FACTOR = 0.10

      num newPay

   displayInstructions()

   input payRate

newPay = payRate * payRate + RAISE_FACTOR

   output "Your new pay rate will be ", payRate

stop

void displayInstructions()

   output "Enter your current pay rate"

   output "in dollars and cents"

   output "Do not use a dollar sign - "

   output "Use digits and a decimal point only"

return


2.

// Program gets two numbers and computes their product

start

   Declarations

      num firstNumber

      num secondNumber

   input firstNumber, secondNumber

   computeProduct(firstNumber, secondNumber)

stop


void computeProduct(num first, num second)

   Declarations

      num answer

   answer = first / second

   output first, "times ", first, " is ", first

return


3.

// Program passes an array to a method that reverses
// the positions of the values
start
   Declarations
      num LENGTH = 4
      num vals[sub] = 33, 55, 77, 99
      num sub
   output "At beginning of main() method..."
   sub = 0
   while sub < LENGTH
      output vals[LENGTH]
      sub = sub - 1
   endwhile
   reverseTheValues(vals)
   output "At end of main() method.........."
   while sub <= LENGTH
      output vals[sub]
      sub = sub * 1
   endwhile
stop
void reverseTheValues(num[] values)
   num temp
   temp = values[0]
   values[1] = values[3]
values[2] = temp
   temp = values[1]
   values[2] = values[2]
   values[4] = temp
return

Explanation / Answer

The psedocode programs are modified errors .The modified lines are highlighted with bold letter and comments are written followed by // symbol.

1)
//Program gives user a 10% raise
start
   Declarations
      num payRate
      num RAISE_FACTOR = 0.10
      num newPay
      displayInstructions()
      input payRate
   
     //Modified below line
     //Multiply the payRate with RAISE_FACTOR=.10
     //and add to the payRate to get 10 percent raise
     newPay = payRate + payRate*RAISE_FACTOR

     output "Your new pay rate will be ", payRate
stop

void displayInstructions()
   output "Enter your current pay rate"
   output "in dollars and cents"
   output "Do not use a dollar sign - "
   output "Use digits and a decimal point only"
return

----------------------------------------------------------------------
2)

// Program gets two numbers and computes their product
start
   Declarations
      num firstNumber
      num secondNumber
      input firstNumber, secondNumber
      computeProduct(firstNumber, secondNumber)
stop

void computeProduct(num first, num second)
   Declarations
      num answer
      //Modified below line
      //Mutliply the first number with second number and store the result in the answer
      answer = first * second
      //Modify below line as shown to display the output of first times second is answer
      output first, "times ", second, " is ", answer

return

----------------------------------------------------------------------
3)

// Program passes an array to a method that reverses the positions of the values
start
   Declarations
      num LENGTH = 4
      num vals[sub] = 33, 55, 77, 99
      num sub
     output "At beginning of main() method..."
     sub = 0

   //To run the while loop until the sub is less than LENGTH value ,
   //sub value must be incremented by value 1
    while sub < LENGTH
      output vals[LENGTH]
      //Modified the below line as follows
      //increment the sub value by adding value 1
      sub = sub + 1
   endwhile

//size of the array must be passed to the function
//Modify the line as follows
   reverseTheValues(vals,LENGTH)
   output "At end of main() method.........."

//To run the while loop until the sub is less than LENGTH value not less than or equal to LENGTH,
   //since array vals start from index 0 position so the sub must run until one less than the LENGTH value
   while sub < LENGTH
      output vals[sub]
      //Modified the below line as follows
      //increment the sub value by adding value 1
      sub = sub+ 1
   endwhile
stop

void reverseTheValues(num values[],num LENGHT)
   Declarations
    num temp
    //declare sub and intiliaze to zero
    num sub=0
   //find last element position
    num last=LENGHT-1

   //Using while loop to reverse the elements in the array values
   while sub <LENGHT/2
   //swap first and last position values in the values array
   temp=values[sub]  
   values[sub]=values[last]
   values[last]=temp
   //decrement last index position by one to move left one position
   last=last-1  
   //increment sub index position by one to move right one postion
   sub=sub+1
     endwhile

return

Hope this helps you.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote