answer.
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
Blizzard [7]
2 years ago
10

Write a method called fact that recursively calculates the factorial value of its single int parameter. The value returned by fa

ct is a long ..
Computers and Technology
1 answer:
andrey2020 [161]2 years ago
6 0

Answer:

The program to this question can be given as follows:

Program:

//class

public class factorial //defining class

{

//method fact

public static long fact(int x1) //defining method fact

{

//conditional statement

if (x1 <= 1) //if block checks parameter value less then equal to 1

{

return 1; //return value

}

else //else part

{

return (fact(x1 - 1) * (long) x1); //return factors using recursive function

}

}

//method main

public static void main(String[] args) //defining main method

{

long data=fact(5);//defining variable that holds function value

System.out.println("Factorial is: "+data); //print value

}

}

Output:

Factorial is: 120

Explanation:

In the above java program, a class is "factorial" is defined, inside the class, a static method "fact" is declared, that accepts an integer parameter that is "x1" and returns a long value, inside this method a conditional statement is used.

  • If the block it checks parameter value is less then equal to 1, if this condition is true, it will return 1 when this condition is not true. It will go in else part.
  • In else part, it uses a recursive function to calculate factorial of a number and return its value.
  • Then the main method is defined, inside this method a long variable "data" is defined, that call and holds fact function return value, and in the next line, the print function is used to print the data variable value.

You might be interested in
When configuring a record type, an App Builder can configure the available value of a picklist field for the page layout. Which
Alla [95]

Answer:

Option (B) and (D) i.e., Type and Lead Source is the correct answer.

Explanation:

Because when the user configures the record type, Then, they can help that user to configure the value of the picklist fields for the page layout. So, The type and the lead source opportunity is available for the standard field that configure straightly in the type of record. That's why the following option is correct.

7 0
2 years ago
Use the values in the range A7:A8 to extend the list of years to the range A9:A11. 3. Use AutoFill to fill the range A9:H11 with
jok3333 [9.3K]

Answer:

Question is incomplete and it needs a proper XL sheet image and more details. I have assumed and answered this question.

1. Use the values in the range A7:A8 to extend the list of years to the range A9:A11

Ans : <em>Use Ctrl + select A7: A8 and drag till A9: A11 : This will extend the list </em>

<em />

<em>2. </em>Use AutoFill to fill the range A9:H11 with the formatting from the range A7:H8.

Ans : Apply format immediately to the cells A9: H11 below with the help of Auto Fill Handle. Using Auto fill button we can able to a cell format to the cell bellow of active cell by just double clicking on the auto fill button.

3. In cell B8, create a formula without using a function that multiplies the value in cell B7 by the value in cell B6 and then adds the value in B7. Update the cell reference to cell B6, from a relative reference to a mixed reference by making an absolute reference to row 

Ans : =($B7*$B6)+$B7

4. Copy the formula from cell B8 to the range B9:B11 and then copy the formulas from the range B8:B11 to the range C8:H11.

Ans:

1. Select the cell B8 that contains which has formula to be copied

2. Click inside the formula bar to activate it and select the entire formula by using mouse and keyboard.

3. Copy the selected formula and press Esc to deactivate the formula bar.

4. Select the cell  B9 : B11 in which you want the copy of the formula to appear.

5. Most range names refer to absolute cell references. This means that when you copy a formula that uses a range name, the copied formula will use the same range name as the original.

6. Paste the formula by using references.

7. Repeat the steps of 1 to 6 for B8:B11 for range C8:H11.

5. Switch to the Cost Estimates worksheet. In cell A9, create a formula using the AVERAGE function that calculates the average of the values in the range A5:A7, then copy your formula to cell D9.

Ans : =AVERAGE(A5:A7) and Copy it to D9 using answer given in 4.

Explanation:

8 0
2 years ago
Mark and John are developing a program using Python. They name a variable 24_hour_mart, but then recognize that this name violat
77julia77 [94]

Answer:

Option 2: Variable names can not begin with a number.

Explanation:

As given Mark and John named a variable as 24_hour_mart while writing a program in python.

While it is forbidden to name a variable starting with any digit, only alphabets (capital and smaller) and underscore can be the first letter of the variable name.

Moreover, by considering the other options given:

  • Variable name can include the underscore (_) between the words. It is used instead of spaces that are not allowed.
  • There is no upper limit for variable length, it can be of any reasonable length and more than 10 characters say 11 or 12 are reasonable.
  • There is no lower limit for variable length, it can be any reasonable length , even it can be of 1 character.

Variables named in python language must not be the keywords as they are reserved for other purposes.

i hope it will help you!

3 0
2 years ago
given:an int variable k,an int array currentMembers that has been declared and initialized,an int variable memberID that has bee
Oksi-84 [34.3K]

Answer:

// The code segment is written in C++ programming language

// The code segment goes as follows

for (k = 0; k < nMembers; k++)

{

//check if memberID can be found in currentMembers

if (currentMembers[k] == memberID){

// If yes,

// assigns true to isAMember

isAMember = true;

k = nMembers;

}

else{

isAMember = false;

// If no

// assigns false to isAMember

}

}

// End of segment:

The following assumption were made in the code segment above.

There exists

1. An already declared and initialised int array currentMembers.

2. An already initialised int variable memberID

Line 3 initiates a loop to scan through the array

Line 6 checks for the condition below

If current element of array equals memberID then

It assigns true to isAMember and nMembers to k

Else

It assigns false to isAMember

7 0
2 years ago
Another solution to minimize resonance is to ________ the bridge.
lakkis [162]
I believe the answer is d
7 0
2 years ago
Other questions:
  • When workers demonstrate patience, are able to manage there emotions, and get along with other employees, which skills are being
    11·2 answers
  • Cooper Technologies is a technology company that offers many IT services in Chicago. The company's services and products include
    6·1 answer
  • In the Budget Details sheet, if you wish to autofill with the formula, you must use a ______ reference for the LY Spend Total ce
    10·1 answer
  • Apart from the challenges of heterogeneity, business and social change and trust and security, identify other problems and chall
    9·1 answer
  • A company requires an Ethernet connection from the north end of its office building to the south end. The distance between conne
    8·1 answer
  • While creating an animation, Gina has prepared a document stating the purpose and type of audience for the animation. What has
    6·1 answer
  • If a class has member variables that are pointers, you must ensure that you implement ____.
    6·1 answer
  • 1. Write a set of routines for implementing several stacks and queues within a single array. Hint: Look at the lecture material
    15·1 answer
  • Which of the following statements is true regarding ARPANET? Select 3 options. It was a product of Bell Laboratories and was int
    9·1 answer
  • Import simplegui
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!