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
RUDIKE [14]
2 years ago
7

A recursive method may call other methods, including calling itself. A recursive method has:

Computers and Technology
1 answer:
kap26 [50]2 years ago
8 0

Answer:

Hence the answer is given as follows,

Explanation:

Base Case:-  

If (num == 0) //This is the base case for the given recursive method  

return 1;  

If(num % 2!=0) checks whether num is odd.  

The above condition is true for all odd numbers and false for even numbers.  

if the remainder is not equal to zero when we divide the number with 2 then it is odd.  

The method:-  

The above recursive method calculates the product of odd numbers up to the given range(that is num)  

For num=5   => 15(5*3*1).  

For num=7   => 105(7*5*3*1).  

For num=10 => 945(9*7*5*3*1).

You might be interested in
A shop will give discount of 10% if the
wlad13 [49]

Answer:

10%÷100 it is correct answer

6 0
3 years ago
Create a brief program that demonstrates use of a Java exception. For example, you could use InputMismatchException and ask the
HACTEHA [7]

Answer:

Here is the program that demonstrates the use of JAVA exception:

import java.util.Scanner;  //to accept input from user

public class Main {  //class name

   public static void main(String[] args) {  //start of main method

      Scanner input = new java.util.Scanner(System.in);  //creates Scanner class object to accept input from user

       int number1 = 0;  //stores the first integer value

       int number2 = 0;  //stores the second integer value

       while(true) {  //keeps looping until user enters integer value

           System.out.println("Enter 2 integers to perform addition: "); //prompts user to enter two integer values

           try {  //defines a chunk of code to check for errors        

               number1 = input.nextInt(); //reads input integer 1

               number2 = input.nextInt(); //reads input integer 2                  

               break;             }  

           catch (java.util.InputMismatchException e) { // defines a code chunk to execute if an error occurs in the try code chunk

              System.out.println("Input must be an integer "); //displays this message if user enters anything other than an integer value

              input.nextLine();              }         }  // reads input from user again until user enters both integer type values

       System.out.println("The sum is: " + (number1+number2));      }  } //if user enters 2 integers then computes and displays the sum of two integer values

Explanation:

The program uses InputMismatchException exception and asks the user to input two integers and computes the sum of two integers if user enters  integers otherwise an exception InputMismatchException is thrown and a error message Input must be an integer is displayed to the user if they input a string of letters instead o f integer values. Here while loop is used which keeps executing until user enters both the integer values. After the user enters correct values, the sum of the two integers are computed and result is displayed on output screen. The screenshot of program and its output is attached.

Another program asks the user to input an integer and the program executes correctly if they enter an integer but exception InputMismatchException is thrown with an error message that is is displayed to the user if they input a string of letters. Here is the program:

import java.util.Scanner;

public class Main {

   public static void main(String[] args) {

       Scanner input = new java.util.Scanner(System.in);

       int number1 = 0;          

       while(true) {

           System.out.println("Enter an integer value: ");        

           try {

               number1 = input.nextInt();  

               break;             }  

           catch (java.util.InputMismatchException e) {

              System.out.println("Input must be an integer ");

              input.nextLine();             }        }  

       System.out.println("The program executed correctly!");  } }

7 0
3 years ago
A​ _______ variable is a variable that has a single numerical​ value, determined by​ chance, for each outcome of a procedure.
7nadin3 [17]
Single variable is the answer
5 0
3 years ago
What design feature of wep makes it a poor choice for wireless network security in larger wireless networks with hundreds or tho
nikklg [1K]
WEP provides no mechanism for automatically changing the shared secret.

Hope this helps :)
~Davinia.
4 0
3 years ago
True or False: The height difference between the paved road and the shoulder may affect the stability of your vehicle.
AlexFokin [52]
I believe the answer to that is true
4 0
3 years ago
Other questions:
  • Websites that are designed to adapt gracefully to any screen size use a technique called
    5·1 answer
  • To delete a database object, right-click the object in the Navigation Pane and then click ____ on the shortcut menu.
    15·1 answer
  • *FREE POINTS* If you comment and follow me this will give up lot of points :p seriously I will follow u back if u do it :p​
    11·2 answers
  • PLEASE HELP ME ON THIS..............PLEASEEEEEEEEEEEE PLEASEEEEEE<br><br> ITTS EASYYYYYYYY
    12·1 answer
  • Rank these three account types in order of decreasing liquidity. Start by picking the most liquid account type first
    13·2 answers
  • An app builder wants to show groups as the last navigation menu item in the Salesforce1 mobile app. However, the app builder is
    8·1 answer
  • Describe how one can change row and height
    6·1 answer
  • If I'm screen sharing and I plug in a HDMI, will it screen share what the HDMI is plugged into, and can you talk at the same tim
    11·1 answer
  • NumA=2<br> for count range (5,8)<br> numA=numA+count <br> print(numA)
    15·1 answer
  • What do earthquakes and tsunamis have in common?
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!