Question: Translate into Java the following pseudo-code, expressed in plain English. Goal: Computes and returns the sum of all the integers between the values of the

 Translate into Java the following pseudo-code, expressed in plain English. Goal:

Translate into Java the following pseudo-code, expressed in plain English. Goal: Computes and returns the sum of all the integers between the values of the parameter "low" and "high". Please note that the values passed as parameter are included in the sum. If someone calls your method with the value for "high" being lesser than that of "low", then your method returns. -1 as a sign there was an error. Variables declarations & initialization: Int variable named "sum", initialized to 0. Steps for the code: If the value given for "high" is lesser than the value given for "low", then we set the variable "sum" to -1. Else, we use a while loop with a condition of the contents of the variable "low" being lesser or equal than the contents of variable "high". In this loop, we increment "sum" ! the value in "low" and then increment "low" by 1. After the end of the loop and the if-else statement, we return the value in "sum". sumOfIntegers(0,5) - 15 sumOfIntegers(1,5) 15 sumOfIntegers(3, 7) 25 Go ...Save, Compile, Run (ctrl-enter) public int sumOfIntegers(int low, int high) { int sum = 0; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!