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
tino4ka555 [31]
3 years ago
7

1) Create a recursive program that prompts the user for a nonnegative integer N and outputs. a) Sum [N] b) BiPower [N] c) TimesF

ive [N] Describe any input constraints in the opening comment of your recursive methods
Computers and Technology
1 answer:
Georgia [21]3 years ago
4 0

Answer:

//Code is created using java

import java.util.*;

// returns the sum

public int sum(int N)

{

if(N==1)

return (1);

else

return N+sum(N-1);

}

// code to return the Bipower ouput

public int BiPower(int N)

{

if(N==1)

return (2);

else

return 2*BiPower(N-1);

}

// Code to return TimesFive output

public int TimesFive(int N)

{

if(N==1)

return 5;

else

return 5 + timesFive(N-1);

}

public static void main(String args[])

   {

//Prompts the user to enter a nonnegative integer

       int N  = Integer.parseInt.(console.readLine("Enter a nonnegative integer:  "));

//Outputs the sum, Bipower and TimesFive

       System.out.println(sum(n));

       System.out.println(BiPower(n));  

       System.out.println(TimesFive(n));

   }

}

You might be interested in
What is theory of knowledge?​
Karolina [17]
Theory of knowledge (TOK) plays a special role in the International Baccalaureate® (IB) Diploma Programme (DP), by providing an opportunity for students to reflect on the nature of knowledge, and on how we know what we claim to know.
4 0
3 years ago
With an example in each, describe the use of two basic functions which are known by the "string.h" header file.
olga nikolaevna [1]

Answer:

strcmp(char * A, char * B);

strcat(char * A, char * B)

Explanation:

One of these basic functions is the function strcmp(char * A, char * B).

This functions compares if two strings are equal; If they are, it returns 0. If not, it returns 1;

So, an example:

char A[13] = "Buffalo Bills";

char B[13] = "Buffalo Bills";

if (strcmp(A,B) == 0)

printf("The strings are the same\n);

else

printf("The strings are not the same");

In this case, they are the same.

----------------------

If for example:

char B[13] = "Buffalo Billz"

It would fall in the else, A and B would not be the same strings.

--------------------------

Other function is the strcat(char * A, char * B);

This function takes two strings as an input, and concatenate them to the first.

For example:

char A[15] = "Buffalo";

char B[5] = "Bills";

strcat(A, B);

printf("%s\n", A);

The output is:

Buffalo Bills

5 0
3 years ago
Need help plz 100 POINTS
steposvetlana [31]

Answer:

salamat sa points wreker

7 0
2 years ago
Read 2 more answers
Is(are) input value(s) to use with a program to test the accuracy of the output.
Law Incorporation [45]

Answer:

test cases

Explanation:

5 0
2 years ago
Read 2 more answers
write an assembly program that uses the output compare function of a timer to toggle an led every second
victus00 [196]

Answer:

...

Explanation:

8 0
2 years ago
Other questions:
  • Use blank to prevent friends who have been drinking from driving
    14·2 answers
  • Write a program that reads in text from standard input (hint: use Scanner) and prints out the number of words in the text. For t
    5·1 answer
  • 1.) How do parks and other green spaces benefit a community?
    7·2 answers
  • You are evaluating the bounce rate of your overall website traffic and find that users with a social media referral source have
    9·1 answer
  • The operating system’s application programming interface (API) provides software developers with tools they use to build applica
    5·1 answer
  • What color mode would you use when designing for web & devices?
    9·1 answer
  • Convert the following denary numbers into binary using 8-bit register:
    6·1 answer
  • Write a for loop that uses the loop control variable to take on the values 0 through 10.
    10·1 answer
  • A(n) _____ is a data validation rule that should be applied to mandatory data items.
    15·1 answer
  • Which combining form is spelled incorrectly? group of answer choices gynic/o carcin/o nephr/o laryng/o
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!