1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
sleet_krkn [62]
3 years ago
7

What is wrong with the following recursive sum method? The method is supposed to sum up the values between 1 and x (for instance

, sum(5) should be 5 + 4 + 3 + 2 + 1 = 15). public int sum(int x) { if (x == 0) return 0; else return sum(x – 1) + x; } Group of answer choices the base case should return 1 instead of 0 the recursive case should return sum(x – 1) + 1; instead of sum(x – 1) + x; the recursive case should return sum(x) + 1; the method should return a boolean instead of an int the base case condition should be (x <= 0) instead of (x = = 0)
Computers and Technology
1 answer:
Karo-lina-s [1.5K]3 years ago
8 0

Answer:

The base case condition should be (x <= 0) instead of (x = = 0)

Explanation:

The given recursive function works fine for positive number. However, it returns an error when the value passed to the function is negative.

To prevent this, the base case should be x <= 0.

This will allow the program returns 0 if a negative number or 0 is passed to the function.

Hence, the changes to be made is to replace the base case with x <= 0

You might be interested in
the front desk of the Nocete's Hotel will comlute the total room sales (TRS) of Room 101.The room was occupied three times and t
Rus_ich [418]

Answer:

Php. 1050

Explanation:

Total Room sales for Room 101:

Rate = 350

Number of times occupied = 3

Total sales per room : (number of times room was occupied * rate of the room.)

Hence, total sales for room 101:

Php. 350 * 3

= Php. 1050

4 0
2 years ago
What are some options available when using the Replace feature?
3241004551 [841]

Assuming that the user is talking about Microsoft Word, the options available when using the replace feature include replace, replace all, and find next. First, the Find what and Replace with boxes locates a word or phrase and replaces it with the new text. Selecting the replace option will update one instance while the replace all option will update all instances without stopping at each one. You can click on the Find Next several times until you come to the instance that you want to update.

8 0
3 years ago
What is the internet​
ZanzabumX [31]
<h2>♨ANSWER♥</h2>

The Internet, sometimes called simply "the Net," is a worldwide system of computer networks -- a network of networks in which users at any one computer can, if they have permission, get information from any other computer

<u>☆</u><u>.</u><u>.</u><u>.</u><u>hope this helps</u><u>.</u><u>.</u><u>.</u><u>☆</u>

_♡_<em>mashi</em>_♡_

5 0
2 years ago
Read 2 more answers
Write a loop that sets newScores to oldScores shifted once left, with element 0 copied to the end. Ex: If oldScores = {10, 20, 3
Katarina [22]

Answer:

The code is as follows:

for(int j = 0; j < newScores.length-1; j++){  

               newScores[j] = oldScores[j+1];  

           }  

           newScores[oldScores.length-1] = oldScores[0];

Explanation:

This loop iterates through the elements of oldScores

for(int j = 0; j < newScores.length-1; j++){  

This enters the elements of oldScores to newScores starting from the element at index 1

               newScores[j] = oldScores[j+1];  

           }  

This moves the first element of index 0 to the last index of newScores

           newScores[oldScores.length-1] = oldScores[0];

7 0
3 years ago
How many spaces should you use for an indent?
vladimir1956 [14]
I believe it's 5 spaces for an indent. If that's incorrect plz forgive me lol.
7 0
3 years ago
Other questions:
  • What view is In a presentation program displays your slides in full screen mode
    6·1 answer
  • When activating windows, which type of volume activation is used to activate multiple windows systems, but must be individually
    12·1 answer
  • Suppose that you created an robot that was so advanced it could act independently in very complex situations. It made its own de
    9·1 answer
  • Through the use of a _____ system, information on prospective, current, and past customers is stored and analyzed for future pla
    15·1 answer
  • The birthday problem is as follows: given a group of n people in a room, what is the probability that two or more of them have t
    15·1 answer
  • When does MMF2 inactivate an Active object? A. When the score is higher than the game's previous high score B. When the player d
    15·1 answer
  • Explain the bad effect and good effect of mobile phone and internet.<br>​
    15·2 answers
  • in a stop-and-wait arq system, the bandwidth of the line is 1 mbps, and 1 bit takes 10 ms to make a round trip. if the system da
    12·1 answer
  • Write an algorithm to find the average of three numbers: 10, 20, 30
    7·1 answer
  • Draw a flow chart to access the marks of three students. calculate the total avarage and display the result​
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!