Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed
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" by 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 sum OfIntegers(1,5) - 15 sumofIntegers(3, 7) - 25

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started