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
nasty-shy [4]
3 years ago
7

Create another method: getFactorial(int num) that calculates a Product of same numbers, that Sum does for summing them up. (1,2,

3 ... num) Make sure you use FOR loop in it, and make sure that you pass a number such as 4, or 5, or 6, or 7 that you get from a Scanner, and then send it as a parameter while calling getFactorial(...) method from main().
Computers and Technology
1 answer:
Mandarinka [93]3 years ago
3 0

Answer:

The program in Java is as follows;

import java.util.*;

public class Main{

public static int getFactorial(int num){

    int fact = 1;

    for(int i =1;i<=num;i++){

        fact*=i;

    }

    return fact;

}

public static void main(String[] args) {

 Scanner input = new Scanner(System.in);

 System.out.print("Number: ");

 int num = input.nextInt();  

 System.out.println(num+"! = "+getFactorial(num)); }}

Explanation:

The method begins here

public static int getFactorial(int num){

This initializes the factorial to 1

    int fact = 1;

This iterates through each digit of the number

    for(int i =1;i<=num;i++){

Each of the digits are then multiplied together

        fact*=i;     }

This returns the calculated factorial

    return fact; }

The main begins here

public static void main(String[] args) {

 Scanner input = new Scanner(System.in);

This prompts the user for number

 System.out.print("Number: ");

This gets input from the user

 int num = input.nextInt();  

This passes the number to the function and also print the factorial

 System.out.println(num+"! = "+getFactorial(num)); }}

You might be interested in
A test's directions often clarify any questions a student might have about answering a response question.
alina1380 [7]
True, hope you have Have a good day
8 0
3 years ago
Read 2 more answers
Name the six parts of the product development life cycle.
Nuetrik [128]

Answer:

Development, Introduction, Growth, Maturity and Decline.

Explanation:

5 0
3 years ago
Read 2 more answers
Which careers have the highest minimum experience requirement?
Dafna11 [192]
(B) CIO, because they make $308,561 per year and it wouldn’t be A cause they only make $140,265 per year nor would C .
8 0
3 years ago
A petrol (gas) station is to be set up for fully automated operation. A driver inputs his or her credit card into the pump, the
malfutka [58]

Answer:

Explanation:

Gas Filling Station has pumps. Pumps have credit card readers. Driver can able to swipe their cards, pumps have Fuel. Pumps card readers communicate with Credit Company. Driver interacts with pump for fuel and credit card.

In this situation the following we need to treat as objects.

They are Pump, Card reader, Fuel tank, communication system, system controller and price table.

Design pattern for the following system is attached below

6 0
3 years ago
How is enviromental factor a disadvantage of communication​
adell [148]

Answer:

Unfavorable climate can act as a barrier to communication leading to wrong perceptions or decision. Noise: Noise is a physical barrier to effective communication. Noise may have its origin from an external source or may exist even in the communication loop. You do not achieve effective communication by merely shouting.

Explanation:

7 0
2 years ago
Other questions:
  • What is pressure?
    7·2 answers
  • How do rubrics increase learning?
    15·2 answers
  • What is the maximum number of fonts that should be used on a slide?
    13·1 answer
  • What does the presence of the cydia app on an ios device indicate?
    14·1 answer
  • Data arranged and stored in a data set
    9·1 answer
  • Why is an ISA unlikely to change between successive generations of microarchitectures
    11·1 answer
  • What does the launcher button do? (From Microsoft Word 2016)
    6·1 answer
  • Write a Python program to convert the characters to lowercase in a string
    6·1 answer
  • Write a method for the Invitation class that accepts a parameter and uses it to update the address for the event.
    9·1 answer
  • Nicole is in a study group to prepare for a test on plant biology, a subject she knows a lot about. During their meetings, she a
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!