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" ! 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

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

Recommended Textbook for

Database Concepts International Edition

Authors: David M. Kroenke

6th Edition International Edition

0133098222, 978-0133098228

More Books

Students also viewed these Databases questions

Question

Provide examples of Dimensional Tables.

Answered: 1 week ago