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]
2 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]2 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
7. Question
Zigmanuir [339]
All server side errors start with 5XX
8 0
3 years ago
Write a 5 – 7+ sentence paragraph about Thanksgiving that DOES NOT use the letter “t.”
Norma-Jean [14]

A period in all of our lives which is recognizing a major bond including family and friends. When summer concludes, a new season comes around bringing a cold, and chilly breeze which is fall. Fall is a special season because occurrences such as leaves falling from conifers, looking for a good pumpkin in the pumpkin field, or simply enjoying  your family and friends company. Drinking warm drinks such as coffee and baking cookies can help you embrace such an amazing season. When fall rolls around, Always be aware of nearby occurrences which can bring you joy during a cold season such as fall.

5 0
2 years ago
Use the drop-down tool to match each definition to the correct word or phrase. The computer that responds to requests from the c
Lera25 [3.4K]

Answer:

The computer that responds to requests from the client computer:  

Server

Connects network devices or different parts of a network:  

Switch

A piece of equipment that directs data where it should go:  

Router

Connects many different Ethernet devices and allows them to connect to the network with one connection:  

Hub

The computer that uses service provided by a server:  

Client

Explanation:

6 0
2 years ago
How does a typewriter involve math and science?
patriot [66]
You have a specific number of words typed a minute and you need to know the science involved in making it
8 0
2 years ago
Read 2 more answers
A(n) _______ is the most basic type of access query
san4es73 [151]
Select Query
I hope this helps! :)
4 0
2 years ago
Other questions:
  • Marie uses a browser to visit a blog. What is the unique identifier of the blog?
    5·1 answer
  • Instructions: Type the correct answer in the box. Spell the word correctly.
    5·2 answers
  • Enzo formed a study group for an upcoming geography test. To start off each session, they go over past notes and look at maps. T
    14·1 answer
  • Nowadays, most online discussion boards are on Web-based forums that provide a variety of user-friendly tools to create and post
    13·1 answer
  • a paragraph is a segment of text with the same format that begins when you press the enter key and ends when you press enter key
    6·2 answers
  • Your unit has an upcoming training event. What form is used to record and maintain document numbers for ammunition documents?
    5·1 answer
  • HELP FOR JAVASCRIPT: 01. What is prototypical inheritance? 02. How can JavaScript be used to improve accessibility on the web? I
    6·1 answer
  • A ____ can be used to enter, display, or edit data
    5·1 answer
  • Describe the impact of improvement ls in technology and transportation on american citizens. ​
    7·1 answer
  • HELP PLZZ WILL MARK BRAINLIEST
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!